Animate the reversal
Original:
↓
Reversed:
1print(" ".join(map(str, reversed(nums))))
Press Animate
Undo a queue, flip a word, rotate a photo carousel — reversing lists is everywhere. Python gives you [::-1] and reversed().
Last item becomes first. Or build a new list from the end.
Reversing means reading items from last to first instead of first to last. If list is [1,2,3], reversed list is [3,2,1].
Used in undo stacks, latest-first feeds, reversing route history, and anytime you need to process most recent items before older ones.
nums[::-1] — slice with step -1 returns a new reversed list.reversed(nums) — returns an iterator; wrap with list() to materialise.nums.reverse() — reverses in-place, changes the original list.In a text editor, undo pops the action stack from the back — that is a reverse traversal. Chat apps show newest messages first — reversed timestamp list.
Original:
Reversed: