Print the list values in reverse in python

Print list in reverse in python programming language in data structures for beginners who is getting ready for interview. This program will print the values from the reverse by using negative value in python data structures.

Slicing can be used to reverse strings. To reverse a string, just build a slice that starts at index 0 and finishes at the length of the string. The slice instruction denotes that the program should begin at the beginning of the string and finish at position 0. It should then proceed with the step -1.

list = ["welcome", "to", "inlarn", "programming"]
print(list[-2])
print(list[-3])
print(list[-4])

 

Output:

inlarn

to

welcome