OpBanana
OpBanana

Reputation: 53

How do I make something print if the input is a number is between 2 different numbers?

Basically, I want to be able to have an input where if a number is between 2 numbers, such as if a number is between 2-8 , it prints "Confirmed.", So if the input is 4,5,6,7 or 8 it will do that.

I've tried this code only, because I couldn't think of anything else.

  if Distance > 1 and < 9:
    print("You should ride your bike.")

I want it to print out "You should ride your bike" if the inputted number is between 2 and 8.

Upvotes: 5

Views: 185

Answers (2)

Arun Pandian k
Arun Pandian k

Reputation: 125

i].you can use and operator

if Distance > 1 and Distance < 9:
    print("You should ride your bike.")

ii].Simple one

if 1 < Distance < 9:
    print("You should ride your bike.")

Upvotes: 1

U13-Forward
U13-Forward

Reputation: 71610

You have to do:

if 1 < Distance < 9:
    print("You should ride your bike.")

Upvotes: 5

Related Questions