Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
program Iterate a list in reverse order
  • Loading branch information
Midhun40 authored Oct 4, 2020
commit 52c2b1b1325620496f5d3bc12a0c3989463a5a2e
22 changes: 22 additions & 0 deletions Iterate a list in reverse order
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

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

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