Q:

python remove list

names = ['Boris', 'Steve', 'Phil', 'Archie']
names.pop(0) #removes Boris
names.remove('Steve') #removes Steve
2
# delete by index
a = ['a', 'b', 'c', 'd']
a.pop(0)
print(a)
['b', 'c', 'd']
6
a = [10, 20, 30, 20]
a.remove(20)
# a = [10, 30, 20]
# removed first instance of argument
8
list.remove(element)
11
l = list(range(10))
print(l)
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

l.clear()
print(l)
# []
-1

New to Communities?

Join the community