You can also do it with recursion:

def reverse(text):
    if len(text) <= 1:
        return text

    return reverse(text[1:]) + text[0]

And a simple example for the string hello:

   reverse(hello)
 = reverse(ello) + h           # The recursive step
 = reverse(llo) + e + h
 = reverse(lo) + l + e + h
 = reverse(o) + l + l + e + h  # Base case
 = o + l + l + e + h
 = olleh
Answer from Blender on Stack Overflow
🌐
Quora
quora.com › How-do-I-reverse-a-string-in-Python-without-slicing-and-indexing
How to reverse a string in Python without slicing and indexing - Quora
Answer (1 of 4): To reverse a string without using slicing and indexing, there can be two possible approaches: 1. for loop: Using for loop, extract the letters/characters of the string one by one and add them to another empty string in reversed order. Output of the above code 2. reversed metho...
Discussions

7 proven methods to reverse the python string in 2021
"".join(sorted(a, reverse=True)) will not reverse a string. >>> a = "hello world" >>> "".join(sorted(a, reverse=True)) 'wroolllhed ' There's a deeper problem with articles like this, though. Reversing a string is a trivial task (i.e., it's something for a beginner to learn). Giving seven different methods with no explanation on if one is better than another is not good teaching, especially when some don't even work and others are pointlessly verbose. More on reddit.com
🌐 r/Python
8
0
December 4, 2021
Method for reversing strings - Ideas - Discussions on Python.org
I would like to add a .reverse() method for strings. I think most modern languages have something like that and [::-1] is a bit archaic with little charm. There may be other methods like splitting the string, reversing the resulting list, and then joining it back, but that’s a bit of work! More on discuss.python.org
🌐 discuss.python.org
2
February 20, 2025
debugging - reversing a string in python without using methods or slicing - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
🌐 stackoverflow.com
Fastest way to reverse a string - and it's not extended string splicing?
I was told there's a faster method with some optimisations possible. If reversing strings is a bottleneck needing optimization, then your codebase might have bigger issues. More on reddit.com
🌐 r/learnpython
70
245
August 12, 2020
🌐
Python Guides
pythonguides.com › python-program-to-reverse-a-string
How To Reverse A String In Python?
January 12, 2026 - Using the reversed() function is a clear and flexible way to reverse a string without slicing, especially when you want to understand how iteration works in Python.
🌐
W3Schools
w3schools.com › python › python_howto_reverse_string.asp
How to reverse a String in Python
There is no built-in function to reverse a String in Python. The fastest (and easiest?) way is to use a slice that steps backwards, -1.
🌐
Reddit
reddit.com › r/python › 7 proven methods to reverse the python string in 2021
r/Python on Reddit: 7 proven methods to reverse the python string in 2021
December 4, 2021 -

How to reverse the python string now in 2021?

Hello to all python buddies,

You're stirring your cofee, and going to read r/Python. And you love the blog post.

Today, I'm going to make r/Python more lovable to you.

I'm going to show you the 6 proven methods to reverse the python string. Which are easy and quick to do.

So, start these methods

☺️

  1. Reverse the string using slice method

You can reverse the string using slice method.

The slice indicates the [start:end] position.

A start is a position where sequence start. and end is the position where sequence ends.

The first position is 0th index.

So, here you can use [::-1].

The [::-1] means sequence starting from last of the string.

For example,

a = ["hello"]

print(a[::-1])

It'll reverse the python string.

>>> olleh

2. Reversed the string using reversed() &join() methods

First of all, the reversed() method reverse the sequence.

After reversed() with you can join() every iterables as string.

Basically, the join() method join the iterables as a string seperator.

reversed() & join()

After running, this code you'll get something like

👇

output

3. Reversed the string: join() and sorted() method

As you know, sorted() sort the string or sequences in ascending or descending method.

Here, I'm going to use descending order.

For descending order, pass reverse = True inside sorted().

And previously, I've told that join joins the sequences as a string seperator.

For example,

join() & sorted()

Here, you can see that first I've sorted the string in descending order.

After that, I've join every character as a string.

When you run above code, you'll get:--->

output

So, you've get the reversed string as output.

4. Reversed the string using for loop

You can reverse the string using for loop.

To create the reverse string in for loop, you need function with empty string.

The every new string add to the empty string.

After adding, all the string it becomes the reverse string.

For example,

code

After running code, you'll get--->

output

So, here you've seen how to reverse the python string. I've told you the 6 methods.

And here I've shown you the 4 methods.

But I'm going to show you 3 methods more.

That means 7 method for reverse the python string.

So, I've given you 1 bonus method.

To get these 3 methods, check out the

👇

https://www.heypython.com/python-programming/reverse-the-python-string/

🌐
CodeSpeedy
codespeedy.com › home › reverse string without using function in python
Reverse string in Python without using function- CodeSpeedy
March 16, 2022 - How to reverse a string in python without using functions. Use of for loop for iterating the string value and concatenating it with an empty string.
🌐
GeeksforGeeks
geeksforgeeks.org › python › reverse-string-python-5-different-ways
How to reverse a String in Python - GeeksforGeeks
We can reverse the string by taking a step value of -1. ... Python provides a built-in function called reversed() which can be used to reverse the characters in a string.
Published   March 3, 2026
Find elsewhere
🌐
Python.org
discuss.python.org › ideas
Method for reversing strings - Ideas - Discussions on Python.org
February 20, 2025 - I would like to add a .reverse() method for strings. I think most modern languages have something like that and [::-1] is a bit archaic with little charm. There may be other methods like splitting the string, reversing the resulting list, and ...
🌐
w3tutorials
w3tutorials.net › blog › reverse-a-string-without-using-reversed-or-1
How to Reverse a String in Python Without Using reversed() or [::-1] — w3tutorials.net
Reversing a string is a common task in programming, often encountered in coding interviews, data processing, or even simple puzzles (like checking for palindromes). Python offers convenient built-in tools for this, such as the `reversed()` function ...
🌐
YouTube
youtube.com › watch
Write A Python Program To Reverse A String Without Using Built-In Functions - YouTube
Hello Programmers, Welcome to my channel.In this video you will learn about how to Write A Python Program To Reverse A String Without Using Built-In Function...
Published   February 16, 2024
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › reverse string in python
Reverse a String in Python – Using Loops, Slicing & Functions
May 13, 2026 - You can reverse a string in Python using a loop. By iterating over the string backwards or using the `reversed()` function combined with `join()`, you can construct a reversed string.
🌐
24HourAnswers
24houranswers.com › technical-tutoring-tips › How-to-Reverse-a-String-in-Python
How to Reverse a String in Python
October 13, 2021 - In Python, the str object does not include a built-in reverse function. If you’re teaching yourself to code, here are a couple things about Python's strings that you should be aware of: In Python, strings are immutable; they can’t be changed. This is so that users can't inadvertently modify the object's content, which helps to avoid errors. Integer, float, tuple, and bool are a few of the other immutable objects in Python. Strings may be sliced.
🌐
Educative
educative.io › answers › how-do-you-reverse-a-string-in-python
How do you reverse a string in Python?
This is a powerful technique that takes advantage of Python’s iterator protocol. This technique reverses a string using reverse iteration with the reversed() built-in function to cycle through the elements in the string in reverse order and then use .join() method to merge all of the characters resulting from the reversed iteration into a new string.
🌐
Sololearn
sololearn.com › en › Discuss › 3334659 › how-can-i-reverse-a-string-without-using-slicing
How can I reverse a string without using slicing? | Sololearn: Learn to code for FREE!
July 29, 2025 - As you go through every character ... print("".join(reversed(input()))) ... Yes, you can reverse a string without slicing by using a loop....
🌐
Javatpoint
javatpoint.com › how-to-reverse-a-string-in-python
How to reverse a string in Python - Javatpoint
How to reverse a string in Python with python, tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, basics, data types, operators, etc.
🌐
Reddit
reddit.com › r/learnpython › fastest way to reverse a string - and it's not extended string splicing?
r/learnpython on Reddit: Fastest way to reverse a string - and it's not extended string splicing?
August 12, 2020 -

An interview question I got was the following:

Write a function that reversed a string s. Speed is important.

I gave them back a 1 liner, returning

s[::-1]

I was told there's a faster method with some optimisations possible.

Some assumptions:

  • Reasonable real world memory limitations.

  • Input string is a valid string.

  • No information on distribution or makeup of strings

How should I have done it?

Top answer
1 of 14
3168

Using slicing:

>>> 'hello world'[::-1]
'dlrow olleh'

Slice notation takes the form [start:stop:step]. In this case, we omit the start and stop positions since we want the whole string. We also use step = -1, which means, "repeatedly step from right to left by 1 character".

2 of 14
329

What is the best way of implementing a reverse function for strings?

My own experience with this question is academic. However, if you're a pro looking for the quick answer, use a slice that steps by -1:

>>> 'a string'[::-1]
'gnirts a'

or more readably (but slower due to the method name lookups and the fact that join forms a list when given an iterator), str.join:

>>> ''.join(reversed('a string'))
'gnirts a'

or for readability and reusability, put the slice in a function

def reversed_string(a_string):
    return a_string[::-1]

and then:

>>> reversed_string('a_string')
'gnirts_a'

Longer explanation

If you're interested in the academic exposition, please keep reading.

There is no built-in reverse function in Python's str object.

Here is a couple of things about Python's strings you should know:

  1. In Python, strings are immutable. Changing a string does not modify the string. It creates a new one.

  2. Strings are sliceable. Slicing a string gives you a new string from one point in the string, backwards or forwards, to another point, by given increments. They take slice notation or a slice object in a subscript:

    string[subscript]
    

The subscript creates a slice by including a colon within the braces:

    string[start:stop:step]

To create a slice outside of the braces, you'll need to create a slice object:

    slice_obj = slice(start, stop, step)
    string[slice_obj]

A readable approach:

While ''.join(reversed('foo')) is readable, it requires calling a string method, str.join, on another called function, which can be rather relatively slow. Let's put this in a function - we'll come back to it:

def reverse_string_readable_answer(string):
    return ''.join(reversed(string))

Most performant approach:

Much faster is using a reverse slice:

'foo'[::-1]

But how can we make this more readable and understandable to someone less familiar with slices or the intent of the original author? Let's create a slice object outside of the subscript notation, give it a descriptive name, and pass it to the subscript notation.

start = stop = None
step = -1
reverse_slice = slice(start, stop, step)
'foo'[reverse_slice]

Implement as Function

To actually implement this as a function, I think it is semantically clear enough to simply use a descriptive name:

def reversed_string(a_string):
    return a_string[::-1]

And usage is simply:

reversed_string('foo')

What your teacher probably wants:

If you have an instructor, they probably want you to start with an empty string, and build up a new string from the old one. You can do this with pure syntax and literals using a while loop:

def reverse_a_string_slowly(a_string):
    new_string = ''
    index = len(a_string)
    while index:
        index -= 1                    # index = index - 1
        new_string += a_string[index] # new_string = new_string + character
    return new_string

This is theoretically bad because, remember, strings are immutable - so every time where it looks like you're appending a character onto your new_string, it's theoretically creating a new string every time! However, CPython knows how to optimize this in certain cases, of which this trivial case is one.

Best Practice

Theoretically better is to collect your substrings in a list, and join them later:

def reverse_a_string_more_slowly(a_string):
    new_strings = []
    index = len(a_string)
    while index:
        index -= 1                       
        new_strings.append(a_string[index])
    return ''.join(new_strings)

However, as we will see in the timings below for CPython, this actually takes longer, because CPython can optimize the string concatenation.

Timings

Here are the timings:

>>> a_string = 'amanaplanacanalpanama' * 10
>>> min(timeit.repeat(lambda: reverse_string_readable_answer(a_string)))
10.38789987564087
>>> min(timeit.repeat(lambda: reversed_string(a_string)))
0.6622700691223145
>>> min(timeit.repeat(lambda: reverse_a_string_slowly(a_string)))
25.756799936294556
>>> min(timeit.repeat(lambda: reverse_a_string_more_slowly(a_string)))
38.73570013046265

CPython optimizes string concatenation, whereas other implementations may not:

... do not rely on CPython's efficient implementation of in-place string concatenation for statements in the form a += b or a = a + b . This optimization is fragile even in CPython (it only works for some types) and isn't present at all in implementations that don't use refcounting. In performance sensitive parts of the library, the ''.join() form should be used instead. This will ensure that concatenation occurs in linear time across various implementations.

🌐
Quora
quora.com › Is-there-a-way-to-reverse-a-string-in-Python-without-using-loops-or-other-methods-that-are-inefficient
Is there a way to reverse a string in Python without using loops or other methods that are inefficient? - Quora
Answer: Efficiency isn’t likely to come into play when reversing a string. Also, there is simply no need to use a loop to reverse a string in Python. Additionally, since strings are immutable, while we say “reverse a string”, we should be clear that what we are doing is “generating ...