Remove Keys from Dictionary - Python

0
10K

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
Financial Services
Macroeconomic perspectives on demand and supply
Key points Keynes’ Law states that demand creates its own supply....
By Mark Lorenzo 2023-03-13 20:40:21 0 12K
Business
Are Social Events and Team Building Organized?
A company’s approach to social events and team building reveals a lot about its culture,...
By Dacey Rankins 2025-08-06 10:37:13 0 3K
Media
The Call (2020)
In the fall of 1987, a group of small-town friends must survive the night in the home of a...
By Leonard Pokrovski 2022-09-08 18:40:18 1 29K
Научная фантастика и фэнтези
Ходячий замок. Howl's Moving Castle. (2004)
Злая ведьма заточила 18-летнюю Софи в тело старухи. Девушка-бабушка бежит из города куда глаза...
By Nikolai Pokryshkin 2023-03-07 23:05:07 0 22K
Martial Arts
Martial Arts: The Ancient Discipline That Transcends Time
Martial Arts: The Ancient Discipline That Transcends Time Martial arts, a term that conjures...
By Leonard Pokrovski 2024-07-01 22:10:48 0 24K

BigMoney.VIP Powered by Hosting Pokrov