Last N Items
Easy · Lists
Lists slice just like strings: items[-3:] is the last 3 items, and slicing past the end is safe. Watch out for one trap: -0 is just 0, so items[-0:] returns the whole list.
Write a function last_n(items, n) that returns the last n items of the list. If n is 0, return an empty list. If n is larger than the list, return the whole list.
Next: Min and Max Together