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. 

Site içinde arama yapın
Kategoriler
Read More
Nature and Science
Blackfish (2013)
A documentary following the controversial captivity of killer whales, and its dangers for both...
By Leonard Pokrovski 2023-07-14 18:39:19 0 24K
Programming
Differences Between For Loop And forEach Loop in JavaScript
for loop forEach loop Generic type of loop and can be used in a variety of scenarios....
By Jesse Thomas 2023-05-29 20:48:24 0 6K
Programming
Proxy Webserver in Python
Socket programming in python is very user friendly as compared to c. The programmer need not...
By Jesse Thomas 2023-03-13 22:09:22 0 6K
Социальные проблемы
Казино. Casino. (1995)
Никто не может сравниться с Сэмом Ротстином. Никто не умеет зарабатывать деньги, как он. Никто не...
By Nikolai Pokryshkin 2023-02-10 12:50:41 0 18K
Music
The Power of Music: A Universal Language of Emotion and Expression
Music has been a cornerstone of human culture for millennia, transcending borders, languages, and...
By Dacey Rankins 2024-12-13 14:35:07 0 3K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov