return value of function looping through list in reverse is the last element in it

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))

>Solution :

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

lt = [1,2,3,4]
print(reverse_list(lt))

Leave a Reply