Notifications
Clear all

Python program to iterate the list in reverse order.

   RSS

0
Topic starter

Output Example:
original list: [10, 20, 30, 40, 50]
list in reverse order: [50, 40, 30, 20, 10]

1 Answer
0
Topic starter

# define a list

list1  = [10, 20, 30, 40, 50]

# print the list

print ("original list: ", list1)

# iterate the list

list1 = list1[::-1]

# print the list

print ("list in reverse order: ", list1)

# another list with string and integer elements

list2 = ['Hello', 10, 'world', 20]

# print the list

print ("Original list: ", list2)

# iterate the list

list2 = list2[::-1]

# print the list

print ("list in reverse order: ", list2)

Share: