Last list element
Returns the last element in a list.
- Use
lst[-1]to return the last element of the passed list.
def last(lst):
return lst[-1]last([1, 2, 3]) # 3Returns the last element in a list.
lst[-1] to return the last element of the passed list.def last(lst):
return lst[-1]last([1, 2, 3]) # 3