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. 

Αναζήτηση
Κατηγορίες
Διαβάζω περισσότερα
Television
ABC 13. KTNV Las Vegas Live TV. USA
KTNV-TV, channel 13, is an ABC-affiliated television station located in Las Vegas, Nevada, United...
από Nikolai Pokryshkin 2022-10-10 10:56:05 0 61χλμ.
Money
How to Increase Your Credit Score
How to Increase Your Credit Score A strong credit score can open doors to better loan rates,...
από Leonard Pokrovski 2025-09-20 16:34:35 0 7χλμ.
Science Fiction and Fantasy
The Terminator. (1984)
A human soldier is sent from 2029 to 1984 to stop an almost indestructible cyborg killing...
από Leonard Pokrovski 2023-04-28 19:18:14 0 29χλμ.
Relationships
Nurturing Relationships in Modern Society: Building Bonds Amidst Change
In the intricate tapestry of society, relationships serve as the threads that bind individuals...
από Dacey Rankins 2024-06-12 15:26:29 0 16χλμ.
Finance
Top 8 Most Expensive Currencies in the World - 2024 Ranking
The size of inflation and interest rates, the scale of unemployment, GDP, fluctuations in stock...
από Dacey Rankins 2024-10-22 17:31:36 0 17χλμ.

BigMoney.VIP Powered by Hosting Pokrov