Remove Keys from Dictionary - Python

0
7K

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
Social Issues
The Cove (2009)
Using state-of-the-art equipment, a group of activists, led by renowned dolphin trainer Ric...
By Leonard Pokrovski 2023-07-06 20:33:34 0 22K
Искусство, культура и развлечения
Тайна Коко. Coco. (2017)
12-летний Мигель живёт в мексиканской деревушке в семье сапожников и тайно мечтает стать...
By Nikolai Pokryshkin 2022-12-29 13:00:25 1 19K
Business
Bloomberg: Plant closures threaten the entire EU auto industry
Volkswagen (VW)'s plans to close its factories in Germany for the first time in history are only...
By Dacey Rankins 2024-09-11 13:54:57 0 9K
Financial Services
Market equilibrium
Key points Supply and demand curves intersect at the equilibrium price. This is the...
By Mark Lorenzo 2023-06-30 19:04:23 0 9K
Programming
JavaScript set()
In JavaScript, a setter can be used to execute a function whenever a specified property is...
By Jesse Thomas 2023-05-17 19:24:16 0 7K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov