Reputation: 11
So, I started making a program and now I require it to print anything I like if the number is between 1-100, How to I make the program realize that it needs to print it if the number's between 90 and 100?
#This is a sample code
F2 = int(input())
if F2 == range(90 , 100):
print("A")
else:
print("BRUH")
I'm really new to this, I'll be very thankful if someone could help me
Upvotes: 1
Views: 336
Reputation: 1017
Use in
operator for membership test. ==
is comparison operator for equality.
print("A" if (F2 := int(input())) in range(90,101) else "BRUH")
Upvotes: 1
Reputation: 1179
Simply do an if else check and if it falls under the range of 90 to 100 then it will print.
#This is a sample code
F2 = int(input())
if F2 >=90 and F2 <=100:
print("A")
else:
print("BRUH")
Upvotes: 1
Reputation: 168
You're checking if f2 is equal to range(90,100), correct form is if it's IN the range(90,100).
if F2 in range(90,101): #last number is not included in range(101 won't be included)
print('A')
also, if you try
f2 = range(90,100)
print(f2)
you'll understand what f2 == range(90,100) means.
if you use in, code will check if f2 in [90,91,92...100] , if f2 will be equal any of them, then returns True.
Upvotes: 2