Remove Keys from Dictionary - Python

0
12K

In order to delete keys from the diction, you would have to use 'del'. Here's an example:

x  = {123: 456}

del x[123]

print(x)

>> {}

 

If the key doesn't exist in the dictionary, it'll throw an KeyError exception. 

Pesquisar
Categorias
Leia Mais
Телевидение
Прямой эфир телеканала ЛенТВ24
"ЛенТВ24" – региональный телеканал, вещающий на Санкт-Петербург и Ленинградскую область....
Por Nikolai Pokryshkin 2022-10-21 13:56:05 0 27K
Marketing and Advertising
Corporate Merch and why its needed
Corporate merchandise is a product or product that a brand or company creates and distributes...
Por FWhoop Xelqua 2023-06-14 17:08:09 0 27K
Life Issues
Before Sunset. (2004)
Nine years after Jesse and Celine first met, they encounter each other again on the French leg of...
Por Leonard Pokrovski 2023-06-16 20:35:25 0 39K
Financial Services
Types of market-oriented environmental tools
Key points The three main categories of market-oriented environmental policies are...
Por Mark Lorenzo 2023-02-07 17:15:56 0 12K
Business
How Can the Product Be More User-Friendly?
User experience (UX) is the cornerstone of any successful product. A product can have...
Por Dacey Rankins 2025-08-18 13:32:38 0 7K

BigMoney.VIP Powered by Hosting Pokrov