Sobes.tech
Junior — Senior

Testing link preservation when reversing the list

livecode

Task condition

Formulate a test that passes a list to the function reverse_list(elements: list) -> list and checks that the returned object is the same object, not a new instance.


def reverse_list(elements: list) -> list:
    elements.reverse()
    return elements

lst = [1, 2, 3]
result = reverse_list(lst)
assert result is lst