Remove Keys from Dictionary - Python

0
5K

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. 

Search
Categories
Read More
Entertainment
The World of Entertainment Arts: An Overview of Its Impact and Diversity
The realm of entertainment arts encompasses a broad spectrum of creative disciplines designed to...
By Dacey Rankins 2024-11-26 15:00:39 0 2K
Business
Digital marketing
Digital marketing is a way to promote goods and services over the Internet. To find new...
By Dacey Rankins 2024-09-03 18:43:08 0 7K
Телевидение
HITTV. Прямой эфир.
HITV — музыкальный телеканал, который создаёт звезд! Мы делаем ставку на новых молодых...
By Nikolai Pokryshkin 2022-10-18 10:31:33 0 21K
Life Issues
Before Sunrise. (1995)
A young man and woman meet on a train in Europe, and wind up spending one evening together in...
By Leonard Pokrovski 2023-03-20 20:33:26 0 13K
Социальные проблемы
Охота. The Hunt. (2012)
42-летний Лукас живет в небольшой датской деревушке, работает воспитателем в детском саду и...
By Nikolai Pokryshkin 2023-01-12 17:44:38 0 15K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov