Remove Keys from Dictionary - Python

0
12KB

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. 

Rechercher
Catégories
Lire la suite
История
Сокровища Сьерра-Мадре. The Treasure of the Sierra Madre. (1948)
В небольшом мексиканском городке Тампико знакомятся два бедняка Доббс и Кертин. От местного...
Par Nikolai Pokryshkin 2023-02-19 18:34:14 0 23KB
Sport
Sisters on Track (2021)
A coming of age story about hope, belonging, and the metaphorical and literal sisterhood of young...
Par Leonard Pokrovski 2022-09-02 18:21:53 0 30KB
Социальные проблемы
Лицо со шрамом. Scarface. (1983)
Весной 1980 года был открыт порт Мэйриэл Харбор, и тысячи кубинских беженцев ринулись в...
Par Nikolai Pokryshkin 2023-01-22 12:18:07 0 30KB
Entertaining
The Art of Home Entertaining: Creating Memorable Experiences for Your Guests
Home entertaining is an age-old tradition that allows hosts to share their space, hospitality,...
Par Dacey Rankins 2024-11-28 15:05:52 0 11KB
Business
What Mistakes Should I Avoid When Trying to Close a Sale?
Closing a sale is one of the most critical steps in the sales process, yet it’s also one of...
Par Dacey Rankins 2025-11-19 20:11:30 0 2KB

BigMoney.VIP Powered by Hosting Pokrov