home
NOTE: Under Construction - I'm in the middle of upgrading my site and lots of stuff is kinda broken. Please forgive the mess.

Remove An Item From A Python List With .remove()

March 2021

** TL;DR

Use .remove() to remove a value from a Python list.

Code
people = ['Jen', 'Greg', 'Jonas']

if 'Greg' in people:
    people.remove('Greg')

print(people)
Results
['Jen', 'Jonas']

If you don't check to see if the value is in the list and try to remove one that isn't there it'll throw an error.

═══ § ═══