I want to create an if/else small program that asks the user to input height and age.
I want the program to first ask the user for height, but ask for the age ONLY if the height is above 120 cm.
If height is bellow 120 cm, the program should terminate without asking for age input.
I seem to not be able to insert an input variable inside an if/else statement.
My program thus far:
print("Welcome to the rollercoaster!")
height = float(input("Please insert height in centimeters:\n"))
print(f"Your height is {int(height)} cm.")
if (height >= 120):
{
print("You can ride the rollercoaster!")
}
else:
{
print("Sorry, you can't ride the rollercoaster! :(")
}
age = int(input("Please insert age:\n"))
if (age <= 18 and height >=120):
{
print("Your ticket costs $7!")
}
elif (age <= 12 and height >=120):
{
print("Your ticket costs $5!")
}
elif (age > 12 and height >=120):
{
print("Your ticket costs $12!")
}
As it is right now, it asks for age regardless of whether the 120cm condition is fulfilled or not.