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. 

Căutare
Categorii
Citeste mai mult
Business
What Are Common Mistakes When Using User Stories?
User stories are one of the most widely adopted tools in Agile product development. They provide...
By Dacey Rankins 2025-08-26 11:42:49 0 7K
Finance
Relationship with money
Relationships with money are one of the areas of life that is strongly charged with projections....
By Dacey Rankins 2024-10-04 15:33:27 0 12K
Business
How to choose the perfect outfit for the office: style tips
Choosing the perfect outfit for the office can be challenging, especially if you want to look...
By Dacey Rankins 2024-09-24 13:32:15 0 15K
Социальные проблемы
Поймай меня, если сможешь. Catch Me If You Can. (2002)
Фрэнк Эбегнейл успел поработать врачом, адвокатом и пилотом на пассажирской авиалинии – и...
By Nikolai Pokryshkin 2023-03-15 18:11:44 0 32K
Телевидение
Прямой эфир ТНТ4.
ТНТ4 — федеральный тематический телеканал с целевой аудиторией 14 – 44, начавший...
By Nikolai Pokryshkin 2022-10-02 08:04:15 1 37K

BigMoney.VIP Powered by Hosting Pokrov