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_func_reversed.asp
Python reversed() Function
Python Examples Python Compiler ... Plan Python Interview Q&A Python Bootcamp Python Training ... The reversed() function returns a reversed iterator object....
🌐
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.
Discussions

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
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
why reversed (list) is iteratorable but list.reverse() is not?
Basically because the reverse() function has a return type of None, it modifies the list in place. It's a call to a function, not to the list itself. Just like you couldn't do reversed_list = list.reverse(), because reversed_list would hold the value of None (But the list variable would still be reversed in-place). Where list[::-1] is a call to the list itself, with instructions on how to iterate through it. More on reddit.com
🌐 r/learnpython
24
12
August 26, 2024
Why does [::1] reverse a string in Python?
On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge. If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options: Limiting your involvement with Reddit, or Temporarily refraining from using Reddit Cancelling your subscription of Reddit Premium as a way to voice your protest. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/learnprogramming
15
12
September 21, 2023
🌐
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 ...
🌐
Programiz
programiz.com β€Ί python-programming β€Ί methods β€Ί built-in β€Ί reversed
Python reversed()
The reversed() function returns an iterator object that provides access to the elements of an iterable (list, tuple, string, etc.) in reverse order. string = 'Python' result = reversed(string) # convert the iterator to list and print it print(list(result)) # Output: ['n', 'o', 'h', 't', 'y', 'P']
🌐
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.
Find elsewhere
🌐
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.
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.

🌐
DataCamp
datacamp.com β€Ί tutorial β€Ί python-reverse-list
Python Reverse List: How to Reorder Your Data | DataCamp
February 27, 2025 - The -1 step moves through the list in reverse order. In Python, reversing a list means changing the order of elements so that the last item appears first and the first item appears last.
🌐
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.

🌐
Medium
medium.com β€Ί @naqvishahwar120 β€Ί reverse-vs-reversed-in-python-9c210e3f125e
reverse() vs reversed() in Python - Shahwar Alam Naqvi - Medium
January 17, 2025 - reverse() vs reversed() in Python Python reverse() Mutating method : It modifies the original list Returns nothing, just changes the list. Works only on List. Example : mera_list = …
🌐
Reddit
reddit.com β€Ί r/pythontips β€Ί [video] python's reverse() vs reversed() - how they differ
r/pythontips on Reddit: [Video] Python's reverse() Vs reversed() - How they differ
January 16, 2024 - On the flip side, reversed() is a function that returns a reversed iterator, allowing you to create a reversed version without altering the original list.
🌐
Medium
medium.com β€Ί @johnidouglasmarangon β€Ί reversing-strings-in-python-immutability-explained-9cc2010be991
Reversing Strings in Python: Immutability Explained | by Johni Douglas Marangon | Medium
January 23, 2025 - While you cannot reverse a string ... you can easily create a new string that is the reverse of the original using slicing, the reversed() function, a loop, or by converting the string to a list and reversing it....
🌐
YouTube
youtube.com β€Ί watch
What "reversed()" ACTUALLY Does In Python - YouTube
In this video I'm going to be showing you what reversed() actually does in Python. In my 3 years of programming in Python, I have never touched it, but it ca...
Published Β  July 15, 2023
🌐
Real Python
realpython.com β€Ί python-reverse-list
Reverse Python Lists: Beyond .reverse() and reversed() – Real Python
June 28, 2023 - Now, how can you reverse a list in place by hand? A common technique is to loop through the first half of it while swapping each element with its mirror counterpart on the second half of the list. Python provides zero-based positive indices to walk sequences from left to right.
🌐
Note.nkmk.me
note.nkmk.me β€Ί home β€Ί python
Reverse a List, String, Tuple in Python: reverse, reversed | note.nkmk.me
August 16, 2023 - In Python, you can reverse a list using the reverse() method, the built-in reversed() function, or slicing. To reverse a string (str) and a tuple, use reversed() or slicing. Reverse a list using the r ...