简体   繁体   English

如果输入的数字在两个不同的数字之间,我该如何打印?

[英]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. 基本上,我希望能够有一个输入,如果一个数字在2个数字之间,例如如果数字在2-8之间,则打印“确认。”,所以如果输入是4,5,6,7或者它会做到这一点。

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. 如果输入的数字在2到8之间,我希望它打印出“你应该骑自行车”。

You have to do: 你必须做:

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

i].you can use and operator 我]。你可以使用and操作员

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

ii].Simple one ii]。简单的一个

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM