How to reverse a string in Python
The fastest, most Pythonic way to reverse a string is slicing with a step of -1: text[::-1]. It works on any string and returns a new, reversed one.
Strings in Python are immutable, so you can't reverse one "in place" — every approach below produces a new string. Each example runs on this page: hit Run, then edit the code and run it again.
1SlicingRecommended
Slicing takes start:stop:step. Leaving start and stop empty and setting step to -1 walks the string backwards — the whole thing, reversed.
Output
This is the go-to method: one line, no imports, and the fastest of the bunch for typical strings.
2reversed() + join()
The built-in reversed() returns an iterator over the characters in reverse; "".join(...) stitches them back into a string. More explicit about intent than slicing.
Output
3A loop (the manual way)
Useful when you're learning how reversal works under the hood: prepend each character to the front of the result as you iterate.
Output
Correct, but slower and more code than slicing — reach for this only when teaching or when you need custom logic per character.
4Which should you use?
| Method | Readability | Speed | Best for |
|---|---|---|---|
| text[::-1] | Great | Fastest | Almost everything |
| "".join(reversed()) | Great | Good | Explicit intent |
| for loop | Verbose | Slowest | Learning / custom logic |
5Common variation: reverse the words
Sometimes you want to reverse the word order, not the characters. Split on whitespace, reverse the list, and join it back:
Output
Frequently asked questions
Can you reverse a string in place in Python?
No. Python strings are immutable, so there’s no in-place reversal — every method returns a brand-new string. If you need a mutable sequence, convert to a list, reverse it, then join back.
Which method is the fastest?
Slicing (text[::-1]) is generally the fastest and is implemented in C under the hood. For most programs the difference is negligible, so prefer whichever reads clearest.
How do I reverse the words instead of the characters?
Use sentence.split() to get a list of words, reverse that list with reversed() or [::-1], then " ".join(...) — see the variation above.
Does reversing work with emoji and accents?
Mostly, but characters made of multiple code points (some emoji, combining accents) can break when reversed naively. For full grapheme-aware reversal, use a library like regex or grapheme.