pop method removes the last element of the python and also return the which element is deleted
l1=[10, 30, 40, 50, 60, 70]
print(l1.pop())
print(l1)
print(l1.pop())
print(l1)
output:
70
[10, 30, 40, 50, 60]
60
[10, 30, 40, 50]
l1=[10, 30, 40, 50, 60, 70]
print(l1.pop())
print(l1)
print(l1.pop())
print(l1)
output:
70
[10, 30, 40, 50, 60]
60
[10, 30, 40, 50]
No comments:
Post a Comment