For a new string with its characters in reverse order, use Python’s slice step -1: text[::-1]. It is the concise default for ordinary Python strings. Use reversed() when you only need to iterate backward, a loop when you need to process characters as you go, and recursion mainly to demonstrate the concept.
Reverse a string with slicing
In Python 3.14, a string is a sequence, and slicing returns a string containing the selected characters. The slice notation is [start:stop:step]; a negative step walks backward. With both bounds omitted, text[::-1] traverses from the end to the beginning. See the Python sequence operations reference and the Python tutorial’s string section.
As an Amazon Associate I earn from qualifying purchases.
text = "Python"
reversed_text = text[::-1]
print(reversed_text) # nohtyP
For reuse, wrap the expression in a function:
def reverse_string(text: str) -> str:
return text[::-1]
The original string is not modified: Python strings are immutable, and the slice produces a new string. An empty string works naturally; reversing "" returns "".
Choose a method for how you will use the result
| Method | Best fit | What it produces |
|---|---|---|
text[::-1] |
Concise, ordinary string reversal | A new string |
reversed(text) |
Reading characters in reverse without needing a string immediately | An iterator |
| Loop with a character list | Learning traversal or applying per-character logic | A new string after joining |
| Recursion | Demonstrating a base case and recursive step on short input | A new string, with recursive calls |
Use reversed() to iterate backward
The built-in reversed() returns an iterator, not a string. Join its characters if a string result is required:
#1 Best Overall
reversed_text = "".join(reversed(text))
If you only need to examine or process characters in reverse order, consume the iterator directly rather than creating a string. The Python FAQ recommends reversed(sequence) for reverse iteration, and the data structures tutorial shows reverse iteration techniques.
Use a loop to make each step visible
This version starts at the last valid index and counts backward, collecting characters in a list before joining them:
Rank #2
def reverse_with_loop(text: str) -> str:
chars = []
for index in range(len(text) - 1, -1, -1):
chars.append(text[index])
return "".join(chars)
The range stops before -1, so index 0 is included. Building a list and joining once avoids repeatedly constructing a growing string inside the loop. Choose this form when the traversal itself matters or each character needs additional handling; otherwise slicing is shorter.
Recursion is useful for a lesson, not a general-purpose default
A recursive definition reverses the tail, then places the first character at the end:
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. This example is suitable for short inputs when teaching recursion. It creates calls proportional to the input length and performs slicing and concatenation along the way, so it is not a practical choice for arbitrarily long strings.
Python’s interpreter limits recursion depth to help prevent runaway recursion from overflowing the C stack. The safe limit depends on the platform; the sys documentation cautions that setting the limit too high can crash the process. Raising it casually is not a fix for this reversal approach.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.What “reverse” means for Python strings
These techniques reverse the order of elements in a Python str. They should not be assumed to preserve every user-perceived visual character as a unit: some displayed characters are made from multiple Unicode code points, such as a base letter followed by a combining mark. If an application needs to reverse visual text units rather than Python string elements, it needs text-segmentation handling beyond the methods shown here.
Free tools Windows power users keep installed
One-click scans. No signup required.
Quick Recap
Best Value
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.




