Skip to content

Instantly share code, notes, and snippets.

@lfalanga
Last active December 15, 2019 01:22
Show Gist options
  • Save lfalanga/8e73a2a462dde82cc114768f75766b96 to your computer and use it in GitHub Desktop.
Save lfalanga/8e73a2a462dde82cc114768f75766b96 to your computer and use it in GitHub Desktop.
# Example 1: Python3 program for pop() method
list1 = [ 1, 2, 3, 4, 5, 6 ]
# Pops and removes the last element from the list
print(list1.pop())
# Print list after removing last element
print("New List after pop : ", list1, "\n")
list2 = [1, 2, 3, ('cat', 'bat'), 4]
# Pop last three element
print(list2.pop())
print(list2.pop())
print(list2.pop())
# Print list
print("New List after pop : ", list2, "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment