Remove Keys from Dictionary - Python
Posted 2023-02-23 23:16:41
0
13K
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.
Căutare
Categorii
- Arts
- Business
- Computers
- Jocuri
- Health
- Home
- Kids and Teens
- Money
- News
- Personal Development
- Recreation
- Regional
- Reference
- Science
- Shopping
- Society
- Sports
- Бизнес
- Деньги
- Дом
- Досуг
- Здоровье
- Игры
- Искусство
- Источники информации
- Компьютеры
- Личное развитие
- Наука
- Новости и СМИ
- Общество
- Покупки
- Спорт
- Страны и регионы
- World
Citeste mai mult
Why do central banks raise interest rates?
Why Do Central Banks Raise Interest Rates?
Interest rates are one of the most powerful tools...
What Is a Startup Incubator?
A startup incubator is an organization designed to support early-stage companies by helping them...
Geography ; World Maps
A geographic chart is a scaled-down, generalized image of the surface of the Earth, another...
How Does a Social Enterprise Differ from a Nonprofit?
In a world where organizations strive to address pressing social and environmental issues, two...
Why is the economy important?
Why Is the Economy Important?
There is a peculiar habit among modern people: they speak of...