Skip to content

Python reversed() function with Example code

  • by

Python reversed() function is used to Reverse the sequence of a list or other iterator object. This function actually returns the reversed iterator of the given sequence and takes a single parameter.

The syntax of reversed() is:


Python reversed() function examples

Simple example code Reverse the sequence of a list, and print each element:

list1 = ["A", "B", "C", "D"]

res = reversed(list1)
for x in res:


Python reversed function

Print reversed list

list1 = ["A", "B", "C", "D"]


Output: [‘D’, ‘C’, ‘B’, ‘A’]

Using reversed() in string, tuple, list, and range

# for string
seq_string = 'Python'

# for tuple
seq_tuple = ('P', 'y', 't', 'h', 'o', 'n')

# for range
seq_range = range(5, 9)

# for list
seq_list = [1, 2, 4, 3, 5]


[‘n’, ‘o’, ‘h’, ‘t’, ‘y’, ‘P’]
[‘n’, ‘o’, ‘h’, ‘t’, ‘y’, ‘P’]
[8, 7, 6, 5]
[5, 3, 4, 2, 1]

Do comment if you have any doubts or suggestions on this Python functions basic topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.