Answers for "get last element of list python when list is empty"

1

python list except last element

>>> myList = list(range(1,5))
>>> myList
[1, 2, 3, 4]
>>> myList = myList[:-1]
>>> myList
[1, 2, 3]
Posted by: Guest on September-23-2020
3

check if is the last element in list python

if x == my_list[-1]:
    # do what you want
Posted by: Guest on August-28-2020

Code answers related to "get last element of list python when list is empty"

Python Answers by Framework

Browse Popular Code Answers by Language