Write a function reverse_first_and_last_halves(items) that reverses the first half of
the list items and the second half of items, in place. Split the list at index
len(items) // 2; when the length is odd the extra element belongs to the second half.
The function returns nothing.
Example
items = [1, 2, 3, 4]
reverse_first_and_last_halves(items)
items -> [2, 1, 4, 3]
Implement this function:
def reverse_first_and_last_halves(items: list) -> None:
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: items.
Input
[1, 2, 3, 4]
Output
[2, 1, 4, 3]