Remove Keys from Dictionary - Python

0
6كيلو بايت

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. 

البحث
الأقسام
إقرأ المزيد
Programming
Python Assert
The assert keyword is used when debugging code. The assert keyword lets you...
بواسطة Jesse Thomas منذ ٢ سنوات 0 6كيلو بايت
القصص
The Croods: A New Age (2020)
The prehistoric family the Croods are challenged by a rival family the Bettermans, who claim to...
بواسطة Leonard Pokrovski منذ ٣ سنوات 0 20كيلو بايت
Programming
JSON Object Literals
JSON object literals are surrounded by curly braces {}. JSON object literals...
بواسطة Jesse Thomas منذ ٢ سنوات 0 6كيلو بايت
Социальные проблемы
Рождество кота Боба. A Christmas Gift from Bob. (2020)
До встречи с котом Бобом Джеймс не любил Рождество, но рыжий пушистый хулиган всё изменил. Он в...
بواسطة Nikolai Pokryshkin منذ ٢ سنوات 0 17كيلو بايت
Социальные проблемы
Расёмон. Rashomon. (1950)
Древняя Япония. В лесу изнасилована женщина, а её муж убит. Есть четыре точки зрения на это...
بواسطة Nikolai Pokryshkin منذ ٢ سنوات 0 13كيلو بايت
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov

Top sites Pokrov