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
Personal Finance
When Is the Best Age to Take Social Security?
When Is the Best Age to Take Social Security? 62 vs. Full Retirement Age vs. 70 Deciding when...
By Leonard Pokrovski 2025-12-11 20:14:55 0 2K
Business
How Long Should a Speech Be?
One of the most common questions in public speaking is:“How long should my speech...
By Dacey Rankins 2025-12-11 16:40:37 0 1K
Intranet
What is an intranet?
An intranet (from the Latin intra – internal – and English net – network) is a...
By Dacey Rankins 2024-03-26 17:03:22 0 24K
Arts, Culture and Entertainment
Annette. (2021)
Los Angeles, nowadays. Henry is a stand-up comedian with a fierce humor. Ann, an internationally...
By Nikolai Pokryshkin 2022-09-01 20:11:00 1 44K
Искусство, культура и развлечения
Поющие под дождём. Singin' in the Rain. (1952)
Основа этого легендарного фильма – дюжина старых песен, написанных для различных...
By Nikolai Pokryshkin 2023-01-07 11:22:38 0 28K

BigMoney.VIP Powered by Hosting Pokrov