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. 

Site içinde arama yapın
Kategoriler
Read More
Internet
How to make Money Online Fast
How to make money quickly on the InternetContentAdvantages and disadvantages of making money on...
By FWhoop Xelqua 2023-05-27 18:59:51 0 23K
Социальные проблемы
Жизнь других. The Lives of Others. (2006)
Сто тысяч сотрудников, двести тысяч информаторов. Вместе они — щит и меч партии, знаменитое...
By Nikolai Pokryshkin 2022-12-15 11:29:22 0 25K
Искусство, культура и развлечения
Престиж. The Prestige. (2006)
Роберт и Альфред - фокусники-иллюзионисты, которые на рубеже XIX и XX веков соперничали друг с...
By Nikolai Pokryshkin 2022-12-02 18:48:38 0 23K
Animation
The Art of Animation: A Journey Through Motion and Imagination
Animation has evolved from simple sketches to complex digital masterpieces, captivating audiences...
By Dacey Rankins 2024-10-17 17:39:28 0 21K
Научная фантастика и фэнтези
Апокалипсис. Дорога сквозь тьму. Broken Darkness. (2021)
После того как метеоритный дождь уничтожил практически все живое на Земле, Сэм вынужден выжить...
By Nikolai Pokryshkin 2022-09-11 22:27:06 0 42K

BigMoney.VIP Powered by Hosting Pokrov