Remove Keys from Dictionary - Python

0
10K

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
Social Issues
Fargo. (1996)
Minnesota car salesman Jerry Lundegaard's inept crime falls apart due to his and his henchmen's...
Por Leonard Pokrovski 2023-03-13 20:28:59 0 23K
Научная фантастика и фэнтези
Бегущий по лезвию. Blade Runner. (1982)
Ноябрь 2019 года. Бывший охотник на андроидов Рик Декард восстановлен в полиции Лос-Анджелеса для...
Por Nikolai Pokryshkin 2023-03-17 14:58:57 0 30K
Life Issues
Aladdin (1992)
A kind-hearted street urchin and a power-hungry Grand Vizier vie for a magic lamp that has the...
Por Leonard Pokrovski 2023-07-01 19:45:10 0 32K
Жизненные вопросы
История семьи Блум. Penguin Bloom. (2021)
Сэм та долго и старательно готовилась к отпуску в кругу семьи в Таиланде, что была настроена на...
Por Nikolai Pokryshkin 2022-09-17 10:30:49 1 31K
Business
What are the different types of business models?
A business model is a company’s strategy for generating revenue and profits by delivering...
Por Dacey Rankins 2025-01-09 15:29:33 0 9K

BigMoney.VIP Powered by Hosting Pokrov