Remove Keys from Dictionary - Python

0
6K

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. 

Search
Categories
Read More
Social Issues
Double Indemnity. (1944)
A Los Angeles insurance representative lets an alluring housewife seduce him into a scheme of...
By Leonard Pokrovski 2023-01-21 21:57:47 0 15K
Научная фантастика и фэнтези
Лабиринт фавна. Pan's Labyrinth. (2006)
Испания, 1944 год. Группа повстанцев сражается с фашистами в горных лесах северной Наварры....
By Nikolai Pokryshkin 2023-02-12 00:24:44 0 20K
Crafts
Arts and Crafts
Arts & Crafts was an English art movement of the Victorian era (late nineteenth century),...
By FWhoop Xelqua 2023-07-01 19:15:47 0 16K
Finance
10 countries with the largest gold reserves.
At the end of 2023, central banks around the world purchased 1037 tons of gold, the second...
By Dacey Rankins 2024-10-22 16:50:43 0 9K
Социальные проблемы
Охотник на оленей. The Deer Hunter. (1978)
История о трех американцах русского происхождения - их жизни до, во время и после войны во...
By Nikolai Pokryshkin 2023-03-30 09:58:29 0 18K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov