-1

this function is supposed to return the list in reverse but instead, it is only returning the last element of the list. I would like to know what is the issue.

def reverse_list(lt):
    for f in lt[::-1]:
        return f
lt = [1,2,3,4]
print(reverse_list(lt))
devuser
  • 7
  • 4

1 Answers1

0
def reverse_list(lt):
    return lt[::-1]

lt = [1,2,3,4]
print(reverse_list(lt))
Lorenzo Bonetti
  • 530
  • 3
  • 12