Remove Keys from Dictionary - Python

0
9K

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. 

Pesquisar
Categorias
Leia Mais
Телевидение
49 канал прямая трансляция.
«НСК 49» – новосибирский телеканал. Новости, кино, шоу, музыка –...
Por Nikolai Pokryshkin 2022-11-23 14:31:45 0 32K
Business
What Skills Are Essential for a CEO?
Being a Chief Executive Officer (CEO) requires more than just experience — it demands a...
Por Dacey Rankins 2025-06-13 17:39:19 0 3K
Социальные проблемы
Капоне. Лицо со шрамом. Capone. (2020)
Вернувшись из тюрьмы, Аль Капоне продолжает оставаться предметом пристального внимания ФБР. Ведь...
Por Nikolai Pokryshkin 2022-10-17 20:59:18 0 28K
Programming
JavaScript set()
In JavaScript, a setter can be used to execute a function whenever a specified property is...
Por Jesse Thomas 2023-05-17 19:24:16 0 9K
Business
How Long Does a Business Consulting Project Usually Take?
Business consulting is a key element in helping organizations improve performance, solve...
Por Dacey Rankins 2025-02-11 15:35:22 0 9K

BigMoney.VIP Powered by Hosting Pokrov