Given a list and we have to iterate it in reverse order in python.
Example:
Input:
List = [10, 20, 30, 40, 50]
Output:
list = [50, 40, 30, 20, 10]
Input;
list = ['Hello', 10 'World', 20]
Output:
list = [20, 'World', 10, 'Hello']
Iterate a list in reverse order
To iterate a list in reverse order, list[::-1] is used. list[::-1] will return the list in reverse order.
Program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer