Python reversed() Function

Returns a reversed iterator object.

Syntax

Python
reversed(sequence)

Parameters

ParameterDescription
sequence Required. Any sequence of objects that supports either the sequence protocols (__len__() and __getitem__()) such as tuple, string, list etc, or an object that implements __reverse__().

Example

Python
range10to15 = range(10, 15)
reversedRange = reversed(range10to15)
for n in reversedRange:
    print(n)

Output

14
13
12
11
10