Remove Keys from Dictionary - Python

0
11K

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. 

Pesquisar
Categorias
Leia Mais
Business
The Top 20 Project Management Questions I Get Asked Most Often
Over the years of working in project management, one thing has become clear—whether I'm...
Por Dacey Rankins 2025-05-19 14:44:28 0 9K
История
Мост через реку Квай. The Bridge on the River Kwai. (1957)
Захваченные в плен японцами британские солдаты и их командир полковник Николсон вынуждены строить...
Por Nikolai Pokryshkin 2023-03-08 13:16:07 0 24K
Information Services
Information Services: The Backbone of the Digital Economy
In today’s increasingly connected world, information is one of the most valuable assets for...
Por Dacey Rankins 2024-11-12 14:42:15 0 12K
Motorsports
The Thrill of Motorsports: Speed, Skill, and Spectacle
The Thrill of Motorsports: Speed, Skill, and Spectacle Motorsports, a captivating blend of...
Por Leonard Pokrovski 2024-07-01 23:13:01 0 22K
Business
What Are the Startup Costs Involved?
Starting a new business is an exciting venture, but it often requires careful planning and an...
Por Dacey Rankins 2025-02-04 15:50:01 0 10K

BigMoney.VIP Powered by Hosting Pokrov