Start of main content
List tail
Python, List · Nov 2, 2020

Returns all elements in a list except for the first one.
- Use slice notation to return the last element if the list's length is more than
1
.
- Otherwise, return the whole list.
def tail(lst):
return lst[1:] if len(lst) > 1 else lst
tail([1, 2, 3])
tail([1])
More like this

Returns all the elements of a list except the last one.
Python, List · Nov 2, 2020

Checks if the elements of the first list are contained in the second one regardless of order.
Python, List · Jan 7, 2021

Returns the difference between two lists, after applying the provided function to each list element of both.
Python, List · Nov 2, 2020