Remove Keys from Dictionary - Python

0
10K

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. 

Site içinde arama yapın
Kategoriler
Read More
Rehber
Judgment at Nuremberg. (1961)
In 1948, an American court in occupied Germany tries four Nazis judged for war crimes. My Link
By Leonard Pokrovski 2023-02-10 14:26:49 0 20K
Business
What Makes Mentoring and Coaching Relationships Effective?
Whether you're working with a mentor or a coach, the effectiveness of the relationship hinges on...
By Dacey Rankins 2025-07-09 14:35:24 0 4K
Jewelry
The most expensive jewelry in the world
Beautiful, alluring, mystical, mysterious... precious stones have always had a special power over...
By FWhoop Xelqua 2022-11-09 17:34:25 0 19K
Научная фантастика и фэнтези
Интерстеллар. Interstellar. (2014)
Когда засуха, пыльные бури и вымирание растений приводят человечество к продовольственному...
By Nikolai Pokryshkin 2022-11-19 17:29:10 0 32K
video
13 Easy Ways to Make Money Watching Videos Online
We all love watching TV and movies – many of us are addicted to watching videos online,...
By FWhoop Xelqua 2022-10-15 18:38:01 0 41K

BigMoney.VIP Powered by Hosting Pokrov