0 votes
1 view
in Python by (11.8k points)

I utilized the above code to reverse a list yet I was asking for what reason is the range(len(my_list)) vital, all the more explicitly, for what reason doesn't it work in the event that I basically "for i in my_list:"?



for i in range(len(my_list)):



1 Answer

0 votes
by (24.6k points)

Try the following code:


for i in range( len(list1) - 1, -1, -1) :

    print(list1[i],end=' ')

Join the python online course fast, to learn python concepts in detail and get certified.

Related questions

0 votes
1 answer
asked Jul 18, 2019 in Java by Shubham (3.9k points)
0 votes
1 answer
0 votes
1 answer
asked Jan 8 in SQL by Appu (6.1k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !