johnrose
0
Q:

python list .remove

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
l = list[1, 2, 3, 4]

for i in range(len(list)):
  l.pop(i) # OR "l.remove(i)"
10
# the list.remove(object) method takes one argument 
# the object or element value you want to remove from the list
# it removes the first coccurence from the list

generic_list = [1, 2, 2, 2, 3, 3, 4, 5, 5, 5, 6, 8, 8, 8]

generic_list.remove(1)

# The Generic list will now be:
# [2, 2, 2, 3, 3, 4, 5, 5, 5, 6, 8, 8, 8]

5
list.remove(element)
11

New to Communities?

Join the community