Remove Keys from Dictionary - Python

0
6KB

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
Stories
For a Few Dollars More. (1965)
Two bounty hunters with the same intentions team up to track down an escaped Mexican outlaw....
Por Leonard Pokrovski 2023-02-02 14:34:20 0 17KB
Roads and Highways
Navigating the World's Arteries: A Comprehensive Look at Roads and Highways
Roads and highways are the lifelines of modern civilization, weaving through landscapes,...
Por Dacey Rankins 2024-05-15 18:29:36 0 9KB
Business
What Should I Look for When Hiring a Business Consultant?
Hiring a business consultant can be one of the best decisions a company makes, especially when...
Por Dacey Rankins 2025-02-11 23:20:31 0 2KB
Business
How AI is Impacting Entrepreneurship
In recent years, Artificial Intelligence (AI) has emerged as a game-changing technology,...
Por Dacey Rankins 2025-03-19 14:55:25 0 2KB
Nature and Science
The Lion King. (1994)
A young lion prince is cast out of his pride by his cruel uncle, who claims he killed his father....
Por Leonard Pokrovski 2022-11-28 21:25:28 0 16KB
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov