Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Semrush - keyword research tool

Create your online store today with Shopify

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Disclosure: My content contains affiliate links.

43,181 questions

56,073 answers

573 users

How to use for loop backwards in Python

3 Answers

0 votes
for i in range(10, 2, -1):
    print(i)





     
'''
run:
     
10
9
8
7
6
5
4
3
     
'''

 



answered May 1, 2021 by avibootz
0 votes
for n in range(10):
    i = 10 - n
    print(i)





     
'''
run:
     
10
9
8
7
6
5
4
3
2
1
     
'''

 



answered May 1, 2021 by avibootz
0 votes
for i in reversed(range(10)):
    print(i)





     
'''
run:
     
9
8
7
6
5
4
3
2
1
0
     
'''

 



answered May 1, 2021 by avibootz

Related questions

2 answers 268 views
268 views asked Apr 13, 2019 by avibootz
1 answer 222 views
1 answer 240 views
1 answer 145 views
6 answers 493 views
493 views asked Apr 23, 2021 by avibootz
14 answers 1,545 views
1,545 views asked Jun 22, 2020 by avibootz
1 answer 321 views
...