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".

Answer from Paolo Bergantino on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_list_reverse.asp
Python List reverse() Method
Python Examples Python Compiler ... Q&A Python Bootcamp Python Certificate Python Training ... The reverse() method reverses the sorting order of the elements....
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-list-reverse
Python List Reverse() - GeeksforGeeks
April 25, 2025 - The reverse() method is an inbuilt method in Python that reverses the order of elements in a list.
Discussions

How do I reverse a string in Python? - Stack Overflow
There is no built in reverse method for Python's str object. How can I reverse a string? More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - How do I reverse a list or loop over it backwards? - Stack Overflow
How do I iterate over a list in reverse in Python? See also: How can I get a reversed copy of a list (avoid a separate statement when chaining a method after .reverse)? More on stackoverflow.com
๐ŸŒ stackoverflow.com
Method for reversing strings - Ideas - Discussions on Python.org
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! There have been several times in my QA career where I am scripting in Python and need to reverse a string, but I have to look up the [::-1] syntax because ... More on discuss.python.org
๐ŸŒ discuss.python.org
1
February 20, 2025
Beginner question: assigning variable to list.reverse()
Any idea why assigning variable Y to this does not result in anything? create a list of prime numbers x = [2, 3, 5, 7] reverse the order of list elements y=x.reverse() print(y) More on discuss.python.org
๐ŸŒ discuss.python.org
0
0
May 12, 2022
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-reversing-list
Reversing a List in Python - GeeksforGeeks
This method builds a reversed version of the list using slicing with a negative step. ... Python's built-in reversed() function is another way to reverse the list.
Published ย  November 26, 2025
Top answer
1 of 14
3162

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.

๐ŸŒ
Reddit
reddit.com โ€บ user โ€บ AMCIS800
amcis800
3 weeks ago - We cannot provide a description for this page right now
Find elsewhere
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ methods โ€บ list โ€บ reverse
Python List reverse()
Become a certified Python programmer. Try Programiz PRO! ... The reverse() method reverses the elements of the list.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_func_reversed.asp
Python reversed() Function
Python Examples Python Compiler ... Q&A Python Bootcamp Python Certificate Python Training ... The reversed() function returns a reversed iterator object....
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ dsa โ€บ program-to-reverse-an-array
Array Reverse - GeeksforGeeks
DSA Python ยท Last Updated : 8 Aug, 2025 ยท Reverse an array arr[]. Reversing an array means rearranging the elements such that the first element becomes the last, the second element becomes second last and so on.
Published ย  August 8, 2025
๐ŸŒ
dbader.org
dbader.org โ€บ blog โ€บ python-reverse-list
How to Reverse a List in Python โ€“ dbader.org
July 11, 2017 - A step-by-step tutorial on the three main ways to reverse a Python list or array: in-place reversal, list slicing, and reverse iteration.
๐ŸŒ
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 tโ€ฆ
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
Beginner question: assigning variable to list.reverse() - Python Help - Discussions on Python.org
May 12, 2022 - Any idea why assigning variable Y to this does not result in anything? create a list of prime numbers x = [2, 3, 5, 7] reverse the order of list elements y=x.reverse() print(y)
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ list-reverse-method
Python List reverse() Method: Syntax, Methods, and Examples
This built-in tool is part of how Python efficiently walks through a list backward. The underlying name comes from the behavior of a built-in reversed mechanism, which is powered by a built-in function.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnprogramming โ€บ why does [::1] reverse a string in python?
r/learnprogramming on Reddit: Why does [::1] reverse a string in Python?
September 21, 2023 -

For example:

txt = "Hello World"[::-1]

Isn't the splice syntax [start : stop: step]? And default of start and stop are the beginning and end of the string? So that would make the above start at the beginning, stop at the end, but step by -1. That feels like it would start at the beginning, then step backwards to...before the beginning of the string?

Sorry for the silly question, I just can't figure out why this syntax works the way it does.

๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ python-reverse-list
Python Reverse List: How to Reorder Your Data | DataCamp
February 27, 2025 - If you're starting your Python ... concepts like list handling and data structures. The easiest way to reverse a list in Python is using slicing ([::-1]), which creates a new reversed list without modifying the original:...
๐ŸŒ
LeetCode
leetcode.com โ€บ problems โ€บ reverse-string
Reverse String - LeetCode
Can you solve this real interview question? Reverse String - Write a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the input array in-place [https://en.wikipedia.org/wiki/In-place_algorithm] with O(1) extra memory.
๐ŸŒ
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/

๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ methods โ€บ built-in โ€บ reversed
Python reversed()
Become a certified Python programmer. Try Programiz PRO! ... The reversed() function returns an iterator object that provides access to the elements of an iterable (list, tuple, string, etc.) in reverse order.
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ tutorial โ€บ datastructures.html
5. Data Structures โ€” Python 3.14.3 documentation
To loop over a sequence in reverse, first specify the sequence in a forward direction and then call the reversed() function.