How to remove an item from a list in Python



In this short tutorial, you will learn how to remove an item from a list in Python using remove and the del keyword. Want to learn more? See our courses here

Read the documentation for lists here:

Code from video:
*****************
company = [‘michael’, ‘eric’, ‘michael’]
company.remove(‘michael’)
company
del company[-1]
company

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

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

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

4 Comments

  1. Hi, I wanted to know if it would be alright to ask a question: whenever I use del listname[x], it seems like Python completely bypasses it and keeps the original list. Would you happen to know why this happens? thank you

  2. i am making a program to help and teach me my times tables.

  3. very useful, I had to answer a question in my coding class for homework and I didn't know what to say so I looked it up on google and found your video so I watched it and it helped me answer the question. 😀 Thanks 😉

Leave a Reply

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