1# Basic syntax:
2my_list.remove(element)
3
4# Note, .remove(element) removes the first matching element it finds in
5# the list.
6
7# Example usage:
8animals = ['cat', 'dog', 'rabbit', 'guinea pig', 'rabbit']
9animals.remove('rabbit')
10print(animals)
11--> ['cat', 'dog', 'guinea pig', 'rabbit'] # Note only 1st instance of
12# rabbit was removed from the list.
13
14# Note, if you want to remove all instances of an element, convert the
15# list to a set and back to a list, and then run .remove(element) E.g.:
16animals = list(set['cat', 'dog', 'rabbit', 'guinea pig', 'rabbit']))
17animals.remove('rabbit')
18print(animals)
19--> ['cat', 'dog', 'guinea pig']
1l = list[1, 2, 3, 4]
2
3for i in range(len(list)):
4 l.pop(i) # OR "l.remove(i)"