check if is the last element in list python
if x == my_list[-1]: # do what you want
Source: stackoverflow.com
how to find the last item of a list
list1 = ['a','b','c'] print(list1[-1])
how to get the last value in a list python
your_list = ["apple", "orange", "grapes"] last_value = your_list[-1]
last element of list python
>>> some_list = [1, 2, 3] >>> some_list[-1] = 5 # Set the last element >>> some_list[-2] = 3 # Set the second to last element >>> some_list [1, 3, 5]
Source: stackoverflow.com
python last item in list
some_list = [1,2,3] some_list[-1] is the shortest and most Pythonic. #output = 3
Source: stackoverflow.com
how to find the last element of list in python
data = ["infy", "tcs", "affle", "dixon", "astral"] last_element = data[-1] print(last_element)
Source: www.howtouselinux.com