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. 

Buscar
Categorías
Read More
Yard, Deck, and Table Games
Yard, Deck, and Table Games: Classic Fun for All Ages
Games have always been a great way to bring people together, whether you’re enjoying a...
By Dacey Rankins 2024-12-05 14:45:29 0 4K
Educación
Health Education: Empowering Individuals and Communities for Better Health
Health education is a vital component of public health that aims to empower individuals and...
By Dacey Rankins 2024-11-21 16:04:40 0 5K
Социальные проблемы
Огни большого города. City Lights. (1931)
Маленький Бродяга встречает красивую слепую девушку, торгующую цветами на улице, которая по...
By Nikolai Pokryshkin 2022-12-10 18:04:28 0 18K
Искусство, культура и развлечения
Престиж. The Prestige. (2006)
Роберт и Альфред - фокусники-иллюзионисты, которые на рубеже XIX и XX веков соперничали друг с...
By Nikolai Pokryshkin 2022-12-02 18:48:38 0 16K
Business
Why is Business Ethics Important?
In today's highly competitive and interconnected world, business ethics plays an essential role...
By Dacey Rankins 2025-01-30 16:01:59 0 3K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov