I am practicing and learning Python, and I had this idea to incorporate if, else statements with input, but it didn't work. So, I tried break, continue and except commands.
name = input("Hello! What's your name?" )
print("Hello," + name + "!")
age = int(input("How old are you? "))
while age <= 13 or age >= 55:
if age < 13:
print("You are too young!")
continue
if age >= 55:
print("You are too old!")
continue
else:
print("Welcome!")
continue
why = input("Why are you here? ")
print("Welcome!")
So, I was trying to go when a person who is over 55 or under 13, it'll boot them out of the input. But, when I tried it, it just printed the print on and on, infinitely.
name = input("Hello! What's your name?" )
print("Hello," + name + "!")
age = int(input("How old are you? "))
while age <= 13 or age >= 55:
if age < 13:
print("You are too young!")
break
if age >= 55:
print("You are too old!")
break
else:
print("Welcome!")
continue
why = input("Why are you here? ")
print("Welcome!")
Here is another one, I tried tweaking it. But what happened is I tried doing break. It did the print but just moved on with the command.
Can someone give me a explanation on why this is happening and how to fix it?