I have written a function that reverses the values of a string:
def reversed_list(in_list):
"""A function that reverses the order
of the items in a list"""
flipped_list = []
[flipped_list.insert(0, in_list[k]) for k, v in enumerate(in_list)]
return flipped_list
reversed_list([1, 2, 3, 4, 5, 6])
It works as expected. However, if I combine the last two lines of the function to become:
return [flipped_list.insert(0, in_list[k]) for k, v in enumerate(in_list)]
The outputted list is [None, None, None...]
Why is this and how can I combine these last two lines to make this code as elegant as possible?
Cheers,