Reversed range doesn't include 0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Newz
    New Member
    • May 2018
    • 1

    Reversed range doesn't include 0

    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)
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    You reverse twice, so it's just
    Code:
    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.

    Comment

    Working...