Write a function first_and_last_index(items, elem) that returns a tuple
(first, last) holding the index of the first occurrence of elem in items and the
index of its last occurrence. If elem occurs exactly once, both indices are the same.
elem is guaranteed to be present in items.
Example
first_and_last_index([1, 2, 3, 2, 1], 2) -> (1, 3)
first_and_last_index([5], 5) -> (0, 0)
Implement this function:
def first_and_last_index(items: list, elem) -> tuple:
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, elem.
Input
[1, 2, 3, 2, 1]
2
Output
(1, 3)