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]) # 3
Returns 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
Finds the index of the last element in the given list that satisfies the provided testing function.
Finds the value of the last element in the given list that satisfies the provided testing function.
Executes the provided function once for each list element, starting from the list's last element.
Returns all the elements of a list except the last one.