1myList.remove(item) # Removes first instance of "item" from myList
2myList.pop(i) # Removes and returns item at myList[i]
1# Example 1:
2# animals list
3animals = ['cat', 'dog', 'rabbit', 'guinea pig']
4# 'rabbit' is removed
5animals.remove('rabbit')
6# Updated animals List
7print('Updated animals list: ', animals)
8
9
10# Example 2:
11# animals list
12animals = ['cat', 'dog', 'dog', 'guinea pig', 'dog']
13# 'dog' is removed
14animals.remove('dog')
15# Updated animals list
16print('Updated animals list: ', animals)
17
18# Example 3:
19# animals list
20animals = ['cat', 'dog', 'rabbit', 'guinea pig']
21# Deleting 'fish' element
22animals.remove('fish')
23# Updated animals List
24print('Updated animals list: ', animals)
1l = list[1, 2, 3, 4]
2l.pop(0) #remove item by index
3l.remove(3)#remove item by value
4#also buth of the methods returns the item
1myList = ['Item', 'Item', 'Delete Me!', 'Item']
2
3del myList[2] # myList now equals ['Item', 'Item', 'Item']
1myList = ['Item', 'Item', 'Delete Me!', 'Item']
2
3myList.pop(2) # myList now equals ['Item', 'Item', 'Item']