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
How Much Should I Have Saved by Age 20/30/40/50/60?
How Much Should I Have Saved by Age 20/30/40/50/60? “How much should I have saved by...
By Leonard Pokrovski 2025-12-03 17:05:15 0 1K
Hospitality
The Future of Hospitality: Trends and Innovations Shaping the Industry in 2024
The hospitality industry is one of the most dynamic sectors of the global economy, constantly...
By Dacey Rankins 2024-11-06 18:06:56 0 12K
Programming
Python Datetime
Datetime in Python is the combination between dates and times. The attributes of this class are...
By Jesse Thomas 2023-03-22 21:22:54 0 11K
Спорт
Ford против Ferrari. Ford v Ferrari. (2019)
В начале 1960-х Генри Форд II принимает решение улучшить имидж компании и сменить курс на...
By Nikolai Pokryshkin 2023-04-13 22:20:33 0 44K
Military
The Evolution of Military Strategy: From Ancient Tactics to Modern Warfare
The Evolution of Military Strategy: From Ancient Tactics to Modern Warfare Introduction: The...
By Leonard Pokrovski 2024-06-10 22:58:14 0 23K

BigMoney.VIP Powered by Hosting Pokrov