Python strings are immutable sequences, so the most direct approach is to create a reversed copy. The slice syntax reads any sequence from right to left when you use a negative step, and it’s the fastest way to reverse a string in typical cases. For user-visible text with emoji, flags, and combined characters, reverse grapheme clusters instead of raw code points to avoid corrupting symbols.
Method 1 — Reverse with slicing (idiomatic and fast)
This uses the standard slice form [start:stop:step], where a step of -1 walks the string from end to start. See Python’s sequence slicing in the docs for strings and sequences.
text = "Hello World"
rev = text[::-1]
print(rev) # dlroW olleH
Optional (many short strings): Precompute the reverse slice once and reuse it.
R = slice(None, None, -1)
for s in ["abc", "racecar", "python"]:
print(s[R])
Join readers who trust AllThings.How
Add us as a preferred source on Google so our practical guides show up first next time you search.
Add to Google Preferences →Method 2 — Use reversed() with join() (readable and flexible)
The built-in iterator reversed() returns characters in reverse order, which you can join into a new string. See the official docs for reversed().
it = reversed("Hello World")
rev = "".join(it)
print(rev) # dlroW olleH
Method 3 — Reverse with a loop (explicit, easiest to trace)
This shows the mechanics but is slower because strings are immutable (each concatenation creates a new string).
rev = ""
for ch in "Hello World":
rev = ch + rev
print(rev) # dlroW olleH
Method 4 — Reverse grapheme clusters for correct emoji and accents (Unicode-safe)
Some visible “characters” are grapheme clusters made of multiple code points (for example, flags, skin-tone modifiers, and combining accents). Reversing raw code points can change meaning, such as turning the UK flag into BG. Unicode grapheme cluster boundaries are defined by UAX #29.
pip install grapheme
import grapheme
clusters = list(grapheme.graphemes("👈🏾👆 🇬🇧 test"))
rev = "".join(clusters[::-1])
print(rev)
Tip: Compare results to see why this matters.
# Code point reversal (may be wrong for some emoji):
print("🇬🇧"[::-1]) # Often shows 🇧🇬
# Grapheme-aware reversal (preserves graphemes as units):
import grapheme
print("".join(list(grapheme.graphemes("🇬🇧"))[::-1])) # Stays 🇬🇧
When to use each method
- Use slicing for most strings; it’s idiomatic and fast.
- Use
reversed()+join()if you prefer iterators or need to plug into APIs that expect iterables. - Use grapheme-aware reversal for user-facing text containing emoji, flags, skin tones, or combining marks.
Pick slicing for performance and simplicity, and switch to grapheme-aware reversal when correctness for emoji and accents matters.






