Remove Keys from Dictionary - Python

0
7كيلو بايت

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. 

البحث
الأقسام
إقرأ المزيد
Business
In Microsoft Office 2024, ActiveX controls will be disabled by default
After the launch of Office 2024 in October, Microsoft will disable ActiveX controls in Word,...
بواسطة Dacey Rankins 2024-09-23 16:42:37 0 12كيلو بايت
Skateboarding
Skateboarding: The Thrill of Artistic Freedom
Skateboarding: The Thrill of Artistic Freedom Skateboarding is more than just a sport; it's a...
بواسطة Leonard Pokrovski 2024-07-08 01:59:39 0 12كيلو بايت
Agriculture and Forestry
Business in Agriculture and Forestry: A Growing Sector
Introduction Agriculture and forestry are vital components of the global economy, providing...
بواسطة Dacey Rankins 2024-10-17 17:09:58 0 18كيلو بايت
Mental Health
Dyslexia: Society and culture
As is the case with any disorder, society often makes an assessment based on incomplete...
بواسطة Kelsey Rodriguez 2023-07-10 17:29:57 0 8كيلو بايت
Algorithms
Algorithm
An algorithm is a clear sequence of actions, the implementation of which gives some kind of...
بواسطة FWhoop Xelqua 2022-12-02 16:56:48 0 21كيلو بايت
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov