Issue
I have a list of 1000 elements. How do I access all of them starting from last element to the first one in a loop.
list = [4,3,2,1]
for item in list:
print(from last to first)
output = [1,2,3,4]
Solution
Try:
list = [4,3,2,1]
print [x for x in list[::-1]]
Output:
[1, 2, 3, 4]
Answered By - Andrés Pérez-Albela H.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.