Question 1
Write a function extract_border_elements(arr) that returns a list with the first and the last element of arr. If arr has only one element, the result has just that element. If arr is empty, the result is an empty list.
NOTE: This is a function type question, you don't have to take input or print the output, just have to complete the required function definition.
Example
extract_border_elements([1, 2, 3, 4]) -> [1, 4]
extract_border_elements([5]) -> [5]
Your task
Implement this function:
def extract_border_elements(arr: list) -> list:
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: arr.
Example
Input
[1, 2, 3, 4]
Output
[1, 4]