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. 

Zoeken
Categorieën
Read More
Telecommunications
Telecommunications: Connecting the World
Telecommunications plays a vital role in our modern society, enabling communication across vast...
By Dacey Rankins 2024-10-15 18:28:20 0 17K
Television
8XM Live TV. Pakistan.
8XM is a Pakistani music television channel, on air since July 2011. 8XM airs all types of music,...
By Nikolai Pokryshkin 2022-11-26 19:01:37 0 40K
Financial Services
Shifts in aggregate supply
Key points The aggregate demand/aggregate supply model is a model that...
By Mark Lorenzo 2023-03-30 19:24:57 0 11K
Социальные проблемы
Лицо со шрамом. Scarface. (1983)
Весной 1980 года был открыт порт Мэйриэл Харбор, и тысячи кубинских беженцев ринулись в...
By Nikolai Pokryshkin 2023-01-22 12:18:07 0 26K
Искусство, культура и развлечения
40-летняя версия. The Forty-Year-Old Version. (2020)
Фильм о том как смириться с тем что тебе 40 и начать действовать в конце концов, а то так и из...
By Nikolai Pokryshkin 2022-10-02 20:24:48 0 41K

BigMoney.VIP Powered by Hosting Pokrov