Find the Last Element of a List in Python Using pop() Function

(Last Updated On: 24/02/2023)

Python Program to Find the Last Element of a List Using the pop() Function

# Get the Last Element of the List in python Using pop() Function

# input list
inputList = [5, 1, 6, 8, 3]

# printing input list
print("Input list:", inputList)

# getting the last element of the list using pop() Function
print("Last element of the input list = ", inputList.pop())

Output:

Input list: [5, 1, 6, 8, 3]
Last element of the input list =  3

Leave a Reply

Your email address will not be published. Required fields are marked *