Back
You can use del , it also supports slices:
>>> q = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]>>> del a[-1]>>> a[1, 2, 3, 4, 5, 6, 7, 8, 9]
Alternatively you can also use pop :
q = ['q', 'w', 'e', 'r']q.pop()# now q is ['q', 'w', 'e']
q = ['q', 'w', 'e', 'r']q.pop()
# now q is ['q', 'w', 'e']
Learn more about Python from an expert. Enroll in our Python Certification Training Course.
You probably want pop:
a = ['a', 'b', 'c', 'd']a.pop(1)
a = ['a', 'b', 'c', 'd']
a.pop(1)
31k questions
32.8k answers
501 comments
693 users