iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Use text[::-1] to create a reversed Python string:
text = "Python"
reversed_text = text[::-1]
print(reversed_text) # nohtyP
The slice walks through the string from end to beginning and returns a new string; it does not change the original. The examples below use Python 3.14 documentation for the language’s sequence and string behavior.
Reverse a string with slicing
For ordinary Python str values, a negative-step slice is the concise default:
def reverse_string(text: str) -> str:
return text[::-1]
A slice has the form [start:stop:step]. The start position is included and the stop position is excluded. With both bounds omitted and a step of -1, Python traverses the sequence backward from its end. See the Python 3.14 common sequence operations and string tutorial.
Free tools Windows power users keep installed
One-click scans. No signup required.
Strings are immutable, so slicing produces a new string rather than modifying the value passed in. An empty string works without a special case: reversing "" returns "".
#1 Best Overall
Reverse iteration with reversed()
If you need a string result, join the reverse iterator:
reversed_text = "".join(reversed(text))
reversed(text) supplies characters in reverse order; "".join(...) assembles them into a string. If you only need to process characters backward, iterate over reversed(text) directly instead of building another string. The Python FAQ recommends reversed() for reverse iteration, and the looping-techniques tutorial covers its use.
Rank #2
Reverse a string with a loop
A loop makes the index movement explicit and gives you a place to add per-character logic:
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsdef reverse_with_loop(text: str) -> str:
chars = []
for index in range(len(text) - 1, -1, -1):
chars.append(text[index])
return "".join(chars)
range(len(text) - 1, -1, -1) starts at the final valid index, moves backward by one, and stops before -1. Characters are collected in a list and joined once at the end, rather than repeatedly building a longer string inside the loop.
Use recursion as a teaching example
This recursive function reverses the tail of the string, then places the first character after it:
def reverse_recursive(text: str) -> str:
if text == "":
return ""
return reverse_recursive(text[1:]) + text[0]
The empty string is the base case. Each recursive call receives a shorter tail, and the original first character is added after that tail has been reversed. Recursion illustrates a base case and a recursive step, but this version is not a practical choice for arbitrarily long strings: it makes calls proportional to input length and creates slices and concatenated strings along the way.
Python limits interpreter recursion depth to help prevent the C stack from overflowing. The safe maximum depends on the platform, so do not raise the limit casually; see the Python 3.14 recursion-limit documentation.
Recommended Free Tools
Which method should you choose?
| Method | Best fit | Result |
|---|---|---|
text[::-1] |
Creating a reversed string with concise, idiomatic code | A new string |
reversed(text) |
Processing characters backward without needing a string result | A reverse iterator |
Loop and join() |
Learning traversal or applying logic as each character is visited | A new string |
| Recursion | Demonstrating recursive structure on short inputs | A new string, with recursion-depth constraints |
These approaches express different needs; no performance ranking is established here.
Best Value
What “reverse” means for Unicode text
These examples reverse the order of elements in a Python str. They do not necessarily preserve what a person sees as a single visual character: emoji sequences and letters combined with accents can consist of multiple Unicode code points. If your application must reverse user-perceived text units while keeping such sequences together, you need text-segmentation handling rather than assuming a basic string slice does that.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

