Remove Keys from Dictionary - Python

0
12KB

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. 

Rechercher
Catégories
Lire la suite
Жизненные вопросы
Пролетая над гнездом кукушки. One flew over the cuckoo's nest. (1975)
Рэндла Патрика Макмёрфи, патологического преступника и бунтаря, переводят из колонии в...
Par Nikolai Pokryshkin 2022-11-13 18:30:48 0 27KB
Contests
The Exciting World of Art Contests: Fostering Creativity and Talent
Art contests have long been a significant part of the creative landscape, providing artists of...
Par Dacey Rankins 2024-12-12 14:28:33 0 10KB
Financial Services
Perfect competition and why it matters
Key points A perfectly competitive firm is a price taker, which means that it...
Par Mark Lorenzo 2023-07-18 20:28:25 0 15KB
Paddleball
Paddleball - what is it?
Paddleball - Paddle-ball Paddleball is a sport that can be played on a half-court court using...
Par FWhoop Xelqua 2022-10-23 15:18:21 0 22KB
Darts
The Art of Darts: Precision, Strategy, and Skill
Darts, a game steeped in tradition yet evolving with the times, continues to captivate...
Par Dacey Rankins 2024-06-20 18:56:44 0 19KB

BigMoney.VIP Powered by Hosting Pokrov