0

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")
asked Jun 27, 2022 at 11:19

1 Answer 1

1

if Y in (X,X+200) will check if Y exists in the tuple consisting of the values X and X+200. You might be looking for the python range function.

if Y in range(X,X+200) should do what you need.

answered Jun 27, 2022 at 11:25
1

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.