Question 1
Write a function get_element_at_circular_index(lst, idx) that returns the element of the non-empty list lst at the index idx, where the indexing is circular: after the last element it goes on from the first element again, and a negative index counts back from the end in the same way. For a list of 3 elements, index 3 is the first element, index 4 is the second element, and index -1 is the last one.
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
get_element_at_circular_index([1, 2, 3], 4) -> 2
get_element_at_circular_index([10, 20, 30, 40], -1) -> 40
Your task
Implement this function:
def get_element_at_circular_index(lst: list, idx: int):
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: lst, idx.
Example
Input
[1, 2, 3]
4
Output
2