Q:

pytho. how to remove from a list

names = ['Boris', 'Steve', 'Phil', 'Archie']
names.pop(0) #removes Boris
names.remove('Steve') #removes Steve
2
a = [10, 20, 30, 20]
a.remove(20)
# a = [10, 30, 20]
# removed first instance of argument
8
# animals list
animals = ['cat', 'dog', 'rabbit', 'guinea pig']

# 'rabbit' is removed
animals.remove('rabbit')

# Updated animals List
print('Updated animals list: ', animals)
3
list.remove(element)
11

Tags

New to Communities?

Join the community