Remove Keys from Dictionary - Python

0
9كيلو بايت

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. 

البحث
الأقسام
إقرأ المزيد
Ужасы
Чужой. Alien. (1979)
В далеком будущем возвращающийся на Землю грузовой космический корабль перехватывает исходящий с...
بواسطة Nikolai Pokryshkin 2022-12-09 13:14:12 1 29كيلو بايت
Business
What is the Lean Startup Methodology?
In the fast-paced world of entrepreneurship, the Lean Startup methodology has become a...
بواسطة Dacey Rankins 2025-03-20 15:04:51 0 7كيلو بايت
Humor
The Art of Recreation: Finding the Fun in the Funny
In a world often shrouded in seriousness, where responsibilities weigh heavy and challenges lurk...
بواسطة Dacey Rankins 2024-05-10 21:54:09 0 12كيلو بايت
Телевидение
Телеканал Бьюти.TV. Прямой эфир.
Бьюти.TV  это телеканал про красоту, актуальные тренды и стильные решения в образах. Легкие...
بواسطة Nikolai Pokryshkin 2022-10-15 11:58:04 0 25كيلو بايت
Developers and Publishers
Video Game Publisher
A computer game publisher is a company that publishes computer games developed internally or by...
بواسطة Dacey Rankins 2024-04-02 17:21:22 0 12كيلو بايت

BigMoney.VIP Powered by Hosting Pokrov