Remove Keys from Dictionary - Python

0
12Кб

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. 

Поиск
Категории
Больше
Personal Finance
How Many Credit Cards Should You Have — and How Does a Credit Card Work?
How Many Credit Cards Should You Have — and How Does a Credit Card Work? Credit cards can...
От Leonard Pokrovski 2025-11-19 22:01:18 0 2Кб
Business
How Can Solopreneurs Stay Motivated and Productive?
Being a solopreneur comes with a unique set of challenges and rewards. While the freedom to work...
От Dacey Rankins 2025-02-13 16:16:54 0 10Кб
Software
Working Out apps
Most running apps connect to your running watch or fitness tracker for accurate workout data....
От FWhoop Xelqua 2023-04-09 18:33:18 0 23Кб
Asia
17 places in Asia where it is worth visiting at least once in a lifetime
Natural phenomena of incredible beauty and structures erected by people with a century of history...
От FWhoop Xelqua 2022-09-19 16:55:01 0 71Кб
Arts
Where Kids and Teens Can Post Art Online for Free
In today’s digital age, young artists have countless opportunities to showcase their...
От Dacey Rankins 2024-10-15 17:28:16 0 19Кб

BigMoney.VIP Powered by Hosting Pokrov