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. 

Pesquisar
Categorias
Leia Mais
Телевидение
Вести Хакасия. ТВ прямой эфир.
В настоящее время филиал ВГТРК ГТРК «Хакасия» является структурным подразделением...
Por Nikolai Pokryshkin 2022-10-24 10:03:37 0 30K
Tennis
Tennis: The Timeless Sport of Skill, Strategy, and Endurance
Tennis: The Timeless Sport of Skill, Strategy, and Endurance Tennis, a sport beloved for its...
Por Leonard Pokrovski 2024-07-11 13:43:40 0 26K
Business
What Are Common Barriers to Innovation, and How Can They Be Overcome?
Innovation is often hailed as the key to progress and growth in any organization or industry....
Por Dacey Rankins 2025-03-20 14:58:44 0 11K
Business
7 Common Conflict Styles That Show Up in Relationships, According to Experts
Conflict is a natural part of any relationship, whether romantic, familial, or professional....
Por Dacey Rankins 2025-06-10 15:16:12 0 11K
By Region
25 OF THE MOST POPULAR SOUVENIRS
Returning from a trip and choosing souvenirs, people tend to buy something special and unique,...
Por FWhoop Xelqua 2022-12-17 14:47:00 0 24K

BigMoney.VIP Powered by Hosting Pokrov