422,538 Members | 2,075 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,538 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)):
print(i)
1 Week Ago #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 589
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.
1 Week Ago #2

Post your reply

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