pyton remove from list code example
Example 1: remove element from list python
animals = ['cat', 'dog', 'rabbit', 'guinea pig']
animals.remove('rabbit')
print('Updated animals list: ', animals)
animals = ['cat', 'dog', 'dog', 'guinea pig', 'dog']
animals.remove('dog')
print('Updated animals list: ', animals)
animals = ['cat', 'dog', 'rabbit', 'guinea pig']
animals.remove('fish')
print('Updated animals list: ', animals)
Example 2: remove item from list python
l = list[1, 2, 3, 4]
for i in range(len(list)):
l.pop(i)