How to delete an item from a dictionary in Python



In this short tutorial, you will learn how to remove an item from a dictionary in Python using the del keyword. Want to learn more? See our Python classes at

Read the documentation for dictionaries here:

Code from video:
*****************
employees= {1: ‘michael’, 2: ‘eric’, 3: ‘michael’}
del employees[2]
employees

Connect with us!
*****************

Nguồn: https://benjaminjcohen.com/

Xem thêm bài viết khác: https://benjaminjcohen.com/cong-nghe/

2 Comments

  1. That's how you delete a Key from a dictionary. But how can you delete an item from it? For example, I have {cars:[black,gray]}, but just want to remove 1 item (i.e audi)

Leave a Reply

Your email address will not be published. Required fields are marked *