Reversing the order of elements in the list


more_fruits.reverse() should reverse it , but upon printing , none is the output

applying .reverse() before store the list in another variable like this:

more_fruits = ['apple', 'banana', 'cherry', 'tomato', 'guava', 'dates']

more_fruits.reverse()
more_fruits_reverse = more_fruits

print(more_fruits_reverse)

# output: ['dates', 'guava', 'tomato', 'cherry', 'banana', 'apple']

@vdsamant-b19 @micaela

reverse() method reverses the list in-place (meaning the original list is modified).
more_fruits and more_fruits_reverse is actually the same for this code (they’re both reversed).

To reverse the list, without modifying it in-place (the original one), you could use reversed() function.

reversed(more_fruits) ← this returns the reversed list.