Remove Keys from Dictionary - Python

0
12KB

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. 

Rechercher
Catégories
Lire la suite
Cooking
Rabbit salad with ham, rice, corn and cucumber
Surprise guests with an unusual dish for the New Year. Salad "Rabbit" with corn, rice and ham, as...
Par FWhoop Xelqua 2022-12-05 16:51:39 0 21KB
Social Issues
Heat. (1995)
A group of high-end professional thieves start to feel the heat from the LAPD when they...
Par Leonard Pokrovski 2023-01-26 17:55:08 0 24KB
Finance
Discount trap: how not to fall for the marketing tricks of car dealerships
Today's auto market is full of enticing offers promising significant discounts and additional...
Par Dacey Rankins 2024-10-04 15:37:40 0 14KB
Sport
The King of Kong: A Fistful of Quarters (2007)
Die-hard gamers compete to break world records on classic arcade games. My Link
Par Leonard Pokrovski 2023-07-25 19:20:21 0 26KB
Business
What Are the Company's Core Values? Ensuring Candidates' Values Align with the Company's Culture
When candidates step into a job interview, they often focus on skills, experience, and...
Par Dacey Rankins 2025-06-19 18:45:03 0 11KB

BigMoney.VIP Powered by Hosting Pokrov