Remove Keys from Dictionary - Python

0
11K

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
Искусство, культура и развлечения
В джазе только девушки. Some Like It Hot. (1959)
Когда чикагские музыканты Джо и Джерри случайно становятся свидетелями бандитской перестрелки,...
By Nikolai Pokryshkin 2023-02-04 21:17:18 0 30K
Construction and Maintenance
The Importance of Construction and Maintenance in Modern Infrastructure
Construction and maintenance are two fundamental pillars that ensure the functionality, safety,...
By Dacey Rankins 2024-11-14 15:59:39 0 13K
Television
FOX 5, Live TV New York USA
New York news, weather, traffic and sports from FOX 5 NY serving New York City, Long Island, New...
By Nikolai Pokryshkin 2022-09-15 08:32:41 0 39K
Business
What Is Viral Growth?
In the digital age, many of the fastest-growing companies—Facebook, TikTok, Dropbox, and...
By Dacey Rankins 2025-09-17 10:44:08 0 3K
Science Fiction and Fantasy
Mad Max: Fury Road. (2015)
In a post-apocalyptic wasteland, a woman rebels against a tyrannical ruler in search for her...
By Leonard Pokrovski 2023-04-06 19:58:58 0 30K

BigMoney.VIP Powered by Hosting Pokrov