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. 

Search
Categories
Read More
Научная фантастика и фэнтези
Звёздные войны: Эпизод 5 — Империя наносит ответный удар. Star Wars: Episode V - The Empire Strikes Back. (1980)
Борьба за Галактику обостряется в пятом эпизоде космической саги. Войска Императора начинают...
By Nikolai Pokryshkin 2022-11-12 13:20:55 0 34K
Business
Coaching vs. Mentoring: Key Differences
While coaching and mentoring are both powerful tools for personal and professional development,...
By Dacey Rankins 2025-07-07 14:46:19 0 6K
Life Issues
One Flew Over the Cuckoo's Nest. (1975)
In the Fall of 1963, a Korean War veteran and criminal pleads insanity and is admitted to a...
By Leonard Pokrovski 2022-11-15 21:26:25 0 25K
Business
How to Effectively Measure Customer Satisfaction: A Guide to CSAT
Customer satisfaction is one of the key metrics of customer service, and it's an axiom. It allows...
By Dacey Rankins 2024-09-19 16:59:32 0 18K
Game Studies
Game-Based Learning
The world of adults is incomprehensible to a small child. Adults do so much! There are police...
By Dacey Rankins 2024-04-04 17:26:15 0 15K

BigMoney.VIP Powered by Hosting Pokrov