Write bookends(items) that returns a two-item list [first, last] holding the first and the last element of items. A one-element list gives that element twice. For an empty list return [].
Examples
Input: items = [4, 8, 15, 16]
Output: [4, 16]
Input: items = [7]
Output: [7, 7]
Constraints
0 <= len(items) <= 5000
Goals
- Read the first item with index 0
- Read the last item with a negative index