使用Python中的If-Else Statment的范围功能
当我输入时 45 200 为什么我没有
原因是if-else语句即将到来 但是我不知道为什么
T = int(input("i"))
for _ in range(T):
X,Y = map (int, input().split(" "))
if Y in (X, X+200):
print("yes")
else:
print("no")
when I enter
45 200
why I am getting no
and the reason is the if-else statement is coming false
but I don't know why
T = int(input("i"))
for _ in range(T):
X,Y = map (int, input().split(" "))
if Y in (X, X+200):
print("yes")
else:
print("no")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果y在(x,x+200)中
将检查y
是否存在于元组中,由值x
和x+ 200
。您可能正在寻找python /a>函数。如果y在范围内(x,x+200)
应该做您需要的事情。if Y in (X,X+200)
will check ifY
exists in the tuple consisting of the valuesX
andX+200
. You might be looking for the pythonrange
function.if Y in range(X,X+200)
should do what you need.