How to reverse for loop? | SoloLearn: Learn to code for FREE!

0

How to reverse for loop?

5/24/2020 1:05:33 AM

Sushank Kangane

5 Answers

New Answer

+5

Sushank Kangane if you write this for index in stride(from: 5, to: 1, by: -1) { print(index) } Then it will print 5 4 3 2 But if you want to print 1 at last position Then you have write for index in stride(from: 5, through: 1, by: -1) { print(index) } Then it will print //prints 5, 4, 3, 2, 1

+5

for a in range(10,-1,-1):

+2

Sushank Kangane you didn't mention...that in which language you need to be learn.... Our mod Jay Matthews tells you in python....

0

0