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. 

Pesquisar
Categorias
Leia Mais
Cycling
The Thrill and Endurance of Cycling Sports: A Journey on Two Wheels
  The Thrill and Endurance of Cycling Sports: A Journey on Two Wheels...
Por Leonard Pokrovski 2024-06-20 04:16:56 0 22K
Television
Fox 13 Salt Lake City. Live TV. USA.
Fox 13 (KSTU), is a Fox-affiliated television station located in Salt Lake City, Utah, United...
Por Nikolai Pokryshkin 2022-10-15 11:08:18 0 37K
Food and Related Products
Food and Related Products: The Heart of Global Industry and Culture
Food is essential to life, but it is also much more than a biological necessity. The production,...
Por Dacey Rankins 2024-11-15 15:12:33 0 14K
Business
What Are Common Mistakes Companies Make During M&A?
Mergers and acquisitions (M&A) represent some of the most ambitious, complex, and high-stakes...
Por Dacey Rankins 2025-11-26 14:10:29 0 893
Social Issues
Gifted. (2017)
Frank, a single man raising his child prodigy niece Mary, is drawn into a custody battle with his...
Por Leonard Pokrovski 2023-05-18 19:45:37 0 33K

BigMoney.VIP Powered by Hosting Pokrov