Quick Answer

The quickest way to reverse a string in Python is slicing: text[::-1]. It builds a new reversed string in a single line and is the fastest, most Pythonic option. Other approaches include reversed() with join(), a for loop, a while loop, and recursion — all shown below with runnable code you can copy and try.

What Reversing a String Means

Reversing a string means flipping the order of its characters, so "cat" becomes "tac". Learning to reverse a string in Python is a classic first exercise, and it is also a favourite interview warm-up. The good news is that Python gives you several clean ways to do it.

One thing to know up front: strings in Python are immutable. You cannot change a string in place — every method here builds and returns a brand-new string, leaving the original untouched. In this tutorial we walk through 5 easy ways, from the shortest one-liner to a full recursion, each with runnable code you can paste straight into a Python file or the interactive shell.

New to the language? Our free Python course covers strings, loops, and functions from scratch, so these examples will click much faster.

Method 1: Slicing with [::-1]

Slicing is the shortest and fastest way, and it is what most experienced Python developers reach for.

text = "Priodemy"
reversed_text = text[::-1]
print(reversed_text)  # ymedoirP

The slice syntax is text[start:stop:step]. Here we leave start and stop empty and set step to -1, which tells Python to walk through the string from the end to the beginning, one character at a time. Because the work happens in optimised C code under the hood, this is the quickest option and the most Pythonic.

When to use it: almost always. It is a single line, it is fast, and any Python developer reading your code will understand it instantly.

Method 2: reversed() + join()

Python has a built-in reversed() function that returns an iterator running backwards over any sequence. On its own it does not give you a string, so you join the characters back together with str.join().

text = "Priodemy"
reversed_text = "".join(reversed(text))
print(reversed_text)  # ymedoirP

Here reversed(text) yields the characters 'y', 'm', 'e', and so on, while "".join(...) glues them into one string with no separator between them. This reads clearly and states your intent out loud — "reverse, then join" — which some people prefer over the slicing trick.

When to use it: when you want code that reads like plain English, or when you already have an iterable of characters rather than a single string.

Method 3: A for Loop

If you are still learning how loops work, building the reversed string by hand is a great exercise. The trick is to add each new character to the front of the result instead of the back.

text = "Priodemy"
reversed_text = ""
for char in text:
    reversed_text = char + reversed_text
print(reversed_text)  # ymedoirP

On each pass we place the current character before everything collected so far. After 'P' we have "P", after 'r' we have "rP", after 'i' we have "irP", and so on until the whole string is flipped. Notice it is char + reversed_text, not reversed_text + char — the order genuinely matters here.

Gotcha: this is slower than slicing because a fresh string is created on every iteration. It is perfect for learning, but it is not what you would ship in performance-sensitive code.

Method 4: A while Loop

A while loop does the same job but gives you full control over the index. We start at the last character and walk backwards to the first.

text = "Priodemy"
reversed_text = ""
index = len(text) - 1
while index >= 0:
    reversed_text += text[index]
    index -= 1
print(reversed_text)  # ymedoirP

len(text) - 1 is the position of the last character, because indexing starts at 0. We append that character, then step the index one place to the left with index -= 1, and stop once it drops below 0.

Gotcha: off-by-one mistakes are easy here. If you start at len(text) instead of len(text) - 1, you will get an IndexError because that position does not exist. This method is verbose, so reach for it only when you specifically need manual index control.

Method 5: Recursion

Recursion means a function that calls itself. To reverse a string, we take the first character, move it to the end, and reverse everything that remains.

def reverse(text):
    if len(text) <= 1:
        return text
    return reverse(text[1:]) + text[0]

print(reverse("Priodemy"))  # ymedoirP

The base case stops the recursion: a string of length 0 or 1 is already its own reverse, so we just return it. Otherwise we reverse everything after the first character (text[1:]) and stick the first character (text[0]) onto the end of that result.

Gotcha: Python limits recursion depth to roughly 1000 calls by default, so this will crash with a RecursionError on very long strings. Treat recursion here as a concept-builder for understanding how self-calling functions work, not as the go-to solution.

Reversing Words vs Characters

So far we reversed the characters of a string. Sometimes you actually want to reverse the order of the words in a sentence while keeping each word readable. These are two different jobs, so it helps to be clear about which you need.

Reverse the words

sentence = "Priodemy makes coding free"
words = sentence.split()
result = " ".join(reversed(words))
print(result)  # free coding makes Priodemy

split() breaks the sentence into a list of words, reversed() flips the order of that list, and " ".join(...) stitches the words back together with spaces. Each word stays spelled correctly — only their positions change.

Reverse the characters

sentence = "hello world"
print(sentence[::-1])  # dlrow olleh

This is the same slicing trick from Method 1 — every character flips, including the spaces. Pick the approach that matches the result you actually want.

Which Method Should You Use?

All five methods produce the same output, so which should you actually use? For everyday code, slicing ([::-1]) is the clear winner — it is the shortest, the fastest, and instantly recognisable to other Python developers. Reach for reversed() + join() when you want a touch more readability. The loops and recursion are best kept as learning tools, or for interviews where you are asked to show the logic by hand.

MethodStyleSpeedRecommended
Slicing [::-1]One lineFastestYes
reversed() + join()One line, readableFastYes
for loopMulti-lineSlowerPartial
while loopMulti-lineSlowerPartial
RecursionMulti-lineSlowestNo

Want to practise these until they stick? Work through strings, lists, and functions step by step in our free Python course and build the muscle memory that makes small problems like this feel easy.

Frequently Asked Questions

What is the fastest way to reverse a string in Python?

Slicing with text[::-1] is the fastest and most Pythonic way. It runs in optimised C code under the hood and reverses the whole string in a single line.

Can you reverse a string in place in Python?

No. Strings in Python are immutable, so you cannot change one in place. Every reversal method builds and returns a new string while the original stays unchanged.

Does Python have a built-in reverse() method for strings?

No. Lists have a .reverse() method, but strings do not. To reverse a string use slicing [::-1] or the built-in reversed() function joined back with "".join().

Why doesn't reversed() print the reversed string directly?

reversed() returns an iterator, not a string. You need to join its characters back together with "".join(reversed(text)) to get a readable string.

How do I reverse the order of words in a sentence?

Split the sentence into words, reverse the list, then join it back: " ".join(reversed(sentence.split())). This flips the word order while keeping each word spelled correctly.