Home >>Python Built-in Functions >Python reversed() Function
Python reversed() function is used to return the reversed iterator object. It returns the given input sequence in the reverse order.
Syntax:reversed(sequence)
Parameter | Description |
---|---|
sequence | This is a required parameter. It defines the iterable object. |
x = [1, 2, 3, 4, 5, 6, 7]
rev = reversed(x)
for a in rev:
print(a)
x = 'Abhimanyu'
rev = reversed(x)
for a in rev:
print(a)