Remove Keys from Dictionary - Python

0
10Кб

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. 

Поиск
Категории
Больше
Camps
Embracing Adventure: The Magic of Recreational Camping
Embracing Adventure: The Magic of Recreational Camping Introduction: Amidst the hustle and...
От Leonard Pokrovski 2024-05-09 10:10:04 0 16Кб
World Records
Happiest Countries in the World
Since 2002, the World Happiness Report has used statistical analysis to determine the world's...
От FWhoop Xelqua 2023-05-16 20:38:59 0 26Кб
Business
What Is Competitive Advantage in Business Strategy?
In today’s fast-paced and competitive business world, the ability to outperform competitors...
От Dacey Rankins 2024-12-25 18:28:06 0 13Кб
Music
Music genres
There are only four musical directions: folk music, sacred music, academic music and popular...
От FWhoop Xelqua 2023-07-07 17:09:02 0 22Кб
Antiques and Collectibles
Unveiling the Timeless Appeal of Antiques and Collectibles
In today's fast-paced world where technology evolves at the blink of an eye, there's a certain...
От Dacey Rankins 2024-05-28 17:31:18 0 20Кб

BigMoney.VIP Powered by Hosting Pokrov