Python Program - Get the Last Element of the List

Here's a Python program that gets the last element of a list:

‮ot refer‬:theitroad.com
my_list = [1, 2, 3, 4, 5]
last_element = my_list[-1]
print(last_element)

In this program, we first create a list called my_list with some integer values.

Then, we use indexing to get the last element of the list. The index -1 refers to the last element of the list, -2 refers to the second-last element, and so on.

Finally, we assign the last element to the variable last_element and print it using the print() function. The output of this program will be:

5