This is what I'm trying to do:
age = input("What is your age?")
if age in range (18,30):
print("You are young")
else:
print("You are old")
What's wrong here? How do I do this range thing properly?
This is what I'm trying to do:
age = input("What is your age?")
if age in range (18,30):
print("You are young")
else:
print("You are old")
What's wrong here? How do I do this range thing properly?
As Devesh said, you need to cast age as an integer by using int(age)
. Furthermore, there is a space between range
and (18,30)
which shouldn't exist.
Change it into:
age = int(input("What is your age?"))
if age in range(18,30):
print("You are young")
else:
print("You are old")