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. 

Cerca
Categorie
Leggi tutto
Finance
How Do I Stop Automatic Debit Payments from My Account?
How Do I Stop Automatic Debit Payments from My Account? Automatic debit payments are a...
By Leonard Pokrovski 2025-10-04 22:05:45 0 5K
Business
Profession head-hunter
A head hunter is a specialist in finding candidates for key, responsible and high positions for...
By Dacey Rankins 2024-09-20 17:22:51 0 13K
Business
Aristotle is the most influential person in philosophy.
Aristotle is the most influential person in philosophy. Aristotle is the most influential...
By Leonard Pokrovski 2024-07-24 12:42:33 0 16K
Agriculture
Three types of Rocks
The 3 Different Names Of Rocks With Examples  Whether you’re an avid rockhound or...
By FWhoop Xelqua 2023-05-13 21:08:36 0 24K
Science Fiction and Fantasy
Blade Runner. (1982)
A blade runner must pursue and terminate four replicants who stole a ship in space and have...
By Leonard Pokrovski 2023-03-18 19:45:03 0 32K

BigMoney.VIP Powered by Hosting Pokrov