List head
Returns the head of a list.
- Use
lst[0]
to return the first element of the passed list.
def head(lst): return lst[0] head([1, 2, 3]) # 1
Returns the head of a list.
lst[0]
to return the first element of the passed list.def head(lst): return lst[0] head([1, 2, 3]) # 1
Merges two or more lists into a list of lists, combining elements from each of the input lists based on their positions.
Learn the difference between Python's built-in list sorting methods and when one is preferred over the other.
Writing efficient Python code can be tricky. Read how we optimize our list snippets to increase performance using a couple of simple tricks.
There's a good way to test the emptiness of a Python list and a better one. Which one are you using?