423,849 Members | 1,876 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,849 IT Pros & Developers. It's quick & easy.

Reversed range doesn't include 0

P: 1
I am new with Python and I don't know how to use the reverse function with range without 0 because I want to make a program to print descending numbers . I tried this one but it doesn't work :
a = int(input())
for i in reversed(range(a, 1)):
May 12 '18 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 599
You reverse twice, so it's just
Expand|Select|Wrap|Line Numbers
  1. for i in reversed(range(1, a)): 
And note that i, l, and O can look like numbers, so use some other letters for single character variable names.
May 13 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.