why not this - it doesn’t mutate the input which seems to better fit the instructions and generally it’s considered a bad practice to mutate function inputs
def reverse(lst):
# Write your code here
node = lst.get_head()
reverse = LinkedList()
while node:
reverse.insert_at_head(node.data)
node = node.next_element
return reverse