0%

🪄 The Mirror Didn’t Lie

The reflection stayed. Only the order shifted. Some truths reveal themselves backwards.
🔮 mirror.reverse()

A mirror does not create a new face. It turns the one you have around. Left becomes right. The beginning becomes the end. The reflection is the same, yet reversed. The reverse() method works the same way. It does not create a new list. It transforms the existing one. The elements stay, but their order flips. The last becomes first. The first becomes last. The mirror did not lie. It just showed you the other side.

🕯️ Magic Note

The reverse() method modifies the list in place. It returns None, so you should not assign its result to a variable. This is different from slicing [::-1], which creates a new reversed list while leaving the original unchanged. reverse() is memory efficient because it rearranges the existing list without copying. The reversal happens in O(n) time, swapping elements from the ends toward the middle.

The syntax mirror.reverse() is called on a list object. After the call, the order of elements in that same list is reversed. If you print the original list before and after, you will see the transformation. The reflection is the same mirror, just flipped.
  • Modifies the list in place, returns None
  • Use reversed(mirror) to get an iterator without changing the original
  • Use mirror[::-1] to create a new reversed list
  • Works on lists only, not tuples or strings (they are immutable)
💡 Use reverse() when you have a list that you want to reverse permanently and no longer need the original order. It is efficient and clear. Use reversed() when you need to iterate in reverse without altering the original list. Use slicing [::-1] when you need a new reversed list for further processing while keeping the original intact. Choose the method that matches your intention and memory requirements.
MethodReturnsOriginal AffectedMemory
list.reverse()NoneYes (in place)No extra list
reversed(list)IteratorNoSmall overhead
list[::-1]New listNoFull copy
⚠️ reverse() modifies the list directly. If you accidentally assign its result to a variable, that variable becomes None and you lose the reference to the reversed list. For example, mirror = mirror.reverse() sets mirror to None, which is a common mistake. Also, reverse() only works on mutable sequences like lists. Trying to reverse a tuple or string will raise an AttributeError.
Examples

Python

# Reversing a list in place

mirror = [1, 2, 3, 4, 5]

print(f”Before: {mirror}”)

mirror.reverse()

print(f”After: {mirror}”)

# Output: Before: [1, 2, 3, 4, 5]

# Output: After: [5, 4, 3, 2, 1]

Python

# Common mistake: assigning the result

words = [“truth”, “mirror”, “reflection”]

result = words.reverse()

print(f”Original list: {words}”)

print(f”Value returned: {result}”)

# Output: Original list: [‘reflection’, ‘mirror’, ‘truth’]

# Output: Value returned: None

# The list is reversed, but result is None

Python

# Reverse vs slice vs reversed

original = [“a”, “b”, “c”, “d”]

# In place reverse

copy_for_reverse = original.copy()

copy_for_reverse.reverse()

print(f”reverse(): {copy_for_reverse}”)

# Slicing creates new list

sliced = original[::-1]

print(f”Slicing: {sliced}”)

# reversed() returns iterator

rev_iter = reversed(original)

print(f”reversed(): {list(rev_iter)}”)

# Output: reverse(): [‘d’, ‘c’, ‘b’, ‘a’]

# Output: Slicing: [‘d’, ‘c’, ‘b’, ‘a’]

# Output: reversed(): [‘d’, ‘c’, ‘b’, ‘a’]

# Original still [‘a’,’b’,’c’,’d’]

Common Mistakes
  • Assigning list.reverse() to a variable, expecting the reversed list but receiving None
  • Trying to reverse a tuple or string with .reverse(), causing an AttributeError
  • Confusing reverse() with reversed(), using one when you need the other

⚡ Whisper

The mirror did not lie. It showed the truth from the other side. The reflection stayed. Only the order shifted. Some truths reveal themselves backwards. You look again and see what was always there, just turned around.