papapasan
0
Q:

python string pop

// no pop methode for strings (strings are immutable)

a = "abc"

last_letter = a[-1]
a = a[:-1]
2
#pop removes the last element
li=[1,2,3,4,5]
li.pop()
#>>>[1, 2, 3, 4]
2
# removes last element of list unless parameter is given
l1 = [1,2,3,4,5]
print(l1.pop()) # returns [1, 2, 3, 4]
print(l1.pop(2)) # returns [1, 2, 4, 5] removes element at given index
0

New to Communities?

Join the community