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. 

Search
Categories
Read More
Programming
Python Asyncio
Asyncio is a library to write concurrent code using the async/await syntax. Asyncio is used as a...
By Jesse Thomas 2023-02-28 23:56:16 0 7K
Arts, Culture and Entertainment
Man with a Movie Camera (1929)
A man travels around a city with a camera slung over his shoulder, documenting urban life with...
By Leonard Pokrovski 2023-07-07 20:48:38 0 23K
Aerospace and Defense
Aviation Industry
Aircraft construction is one of the most profitable and at the same time the most...
By FWhoop Xelqua 2023-07-16 17:12:17 0 18K
Financial Services
Shifts in aggregate supply
Key points The aggregate demand/aggregate supply model is a model that...
By Mark Lorenzo 2023-03-30 19:24:57 0 8K
Business
ANALYSIS AS A FUNCTIONAL ELEMENT OF BUSINESS PROCESS MANAGEMENT IN THE ORGANIZATION
The management of the activities of any organization is based on the use of various approaches...
By Dacey Rankins 2024-09-23 14:52:25 0 11K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov