To get a new reversed list, apply the reversed function and collect the items into a list:

>>> xs = [0, 10, 20, 40]
>>> list(reversed(xs))
[40, 20, 10, 0]

To iterate backwards through a list:

>>> xs = [0, 10, 20, 40]
>>> for x in reversed(xs):
...     print(x)
40
20
10
0
Answer from codaddict on Stack Overflow
🌐
W3Schools
w3schools.com › python › ref_list_reverse.asp
Python List reverse() Method
Python Examples Python Compiler ... Bootcamp Python Certificate Python Training ... The reverse() method reverses the sorting order of the elements....
🌐
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.
🌐
Mimo
mimo.org › glossary › python › list-reverse-method
Python List reverse() Method: Syntax, Methods, and Examples
The reverse() method does not return a new list—it returns None. If you use reverse() right after you append a value to the end of the list, you’ll see the new value appear first after reversal. When you want to modify the list directly without creating a new one. Useful in memory-sensitive contexts. Great when working with an existing list you don't need to preserve. This is a concise and elegant way to reverse a list in Python.
🌐
DataCamp
datacamp.com › tutorial › python-reverse-list
Python Reverse List: How to Reorder Your Data | DataCamp
February 27, 2025 - The reverse() method is efficient for memory since it doesn't require creating a copy of the list. However, it permanently changes the order of elements in the original list, so it's best used when the initial list is not needed in its original order. #Python Example: Reversing a list in place numbers = [1, 2, 3, 4, 5] numbers.reverse() print(numbers) #Output: [5, 4, 3, 2, 1]
🌐
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.
🌐
Real Python
realpython.com › ref › builtin-functions › reversed
reversed() | Python’s Built-in Functions – Real Python
The built-in reversed() function takes a sequence as an argument and returns an iterator that yields the elements in reverse order.
🌐
W3Schools
w3schools.com › python › ref_func_reversed.asp
Python reversed() Function
Python Overview Python Built-in Functions Python String Methods Python List Methods Python Dictionary Methods Python Tuple Methods Python Set Methods Python File Methods Python Keywords Python Exceptions Python Glossary · Built-in Modules Random Module Requests Module Statistics Module Math Module cMath Module · Remove List Duplicates Reverse a String Add Two Numbers
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-reversed-function
Python reversed() Method - GeeksforGeeks
February 17, 2026 - reversed() function in Python returns an iterator that accesses elements in reverse order. It does not create a new reversed copy of the sequence, making it memory-efficient. It works with sequence types like lists, tuples, strings and ranges ...
🌐
Programiz
programiz.com › python-programming › methods › built-in › reversed
Python reversed()
string = 'Python' result = ... argument. iterable - an iterable such as list, tuple, string, dictionary, etc. The reversed() method returns an iterator object....
🌐
Tutorialspoint
tutorialspoint.com › python › list_reverse.htm
Python List reverse() Method
The Python List reverse() method reverses a list. That means, the first object in the list becomes the last object and vice versa. Another common technique used to reverse a string is done using the slicing operator with the syntax [::-1].
🌐
Educative
educative.io › answers › how-to-use-the-reverse-and-reversed-methods-in-python
How to use the reverse() and reversed() methods in Python
The list class in Python has built-in reverse() function, which when called, reverses the order of all the elements in the list. This function does not take any argument and reverses the object on which it is called upon.
🌐
Cherry Servers
cherryservers.com › home › blog › python › how to reverse a list in python (using 3 simple ways)
How to Reverse a List in Python (Using 3 Simple Ways) | Cherry Servers
November 7, 2025 - To reverse a list in Python, two basic methods are commonly used, the built-in reverse() method and slicing with [::-1].
🌐
Real Python
realpython.com › python-reverse-list
Reverse Python Lists: Beyond .reverse() and reversed() – Real Python
June 28, 2023 - Like other mutable sequence types, Python lists implement .reverse(). This method reverses the underlying list in place for memory efficiency when you’re reversing large list objects.
🌐
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)
🌐
Python.org
discuss.python.org › ideas
Method for reversing strings - Ideas - Discussions on Python.org
February 20, 2025 - 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 ...
🌐
W3Schools
w3schools.com › python › python_howto_reverse_string.asp
How to reverse a String in Python
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... Learn how to reverse a String in Python.
🌐
Real Python
realpython.com › reverse-string-python
Reverse Strings in Python: reversed(), Slicing, and More – Real Python
July 31, 2023 - Inside ReversibleString, you create .reverse(). This method reverses the wrapped string in .data and reassigns the result back to .data. From the outside, calling .reverse() works like reversing the string in place.
🌐
Codecademy
codecademy.com › article › how-to-reverse-a-list-in-python
How to Reverse a List in Python | Codecademy
Learn how to reverse a list in Python using `.reverse()`, `reversed()`, slicing, the two-pointer method, loops, and recursion with examples.
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.