Remove Keys from Dictionary - Python

0
6K

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
Mental Health
ADHD: Exercise
Regular physical exercise, particularly aerobic exercise, is an effective add-on treatment for...
By Kelsey Rodriguez 2023-05-03 17:41:29 0 6K
Business
Psychology of outdoor advertising: how it affects our behavior
  Imagine a city street without bright signs, billboards and glowing screens –...
By Dacey Rankins 2024-09-18 16:44:30 0 9K
Arts, Culture and Entertainment
The Forty-Year-Old Version. (2020)
Radha is a down-on-her-luck NY playwright, who is desperate for a breakthrough before 40....
By Leonard Pokrovski 2022-10-03 20:45:31 0 18K
Политика
Фэнтезийный мир на смену фантастике.
«В ФЭНТЕЗИЙНОМ ЖАНРЕ НЕТ НИ ДЕМОКРАТИИ, НИ ПРОГРЕССА — ЭТО БУДУЩЕЕ КАК...
By Sergey Sokolov 2023-01-24 15:27:10 0 21K
Programming
Difference between C++ and JavaScript
C++ or CPP is a general-purpose statically typed object-oriented programming language. In 1980,...
By Jesse Thomas 2023-06-06 20:53:20 0 6K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov