0

Here's my code.

def function():
    rng = randint(1,10)
    if rng == 1 or 2 or 3 or 4 or 5:
        print "option 1"
    elif rng == 6:
        print "option 2"
    elif rng == 7:
        print "option 3"
    else:
        print "option 4"

In the blank space in the if statement, I want the code to consider if rng equals a range of integers from 1 to 5. When I run this function, it always prints out "option 1", leading me to believe there's something wrong with the if statement, causing the code to automatically print option 1 and discard all other code. Is there another way to express "if rng == 1 to 5"?

0 Answers0