0
Repeat question if ELSE is not correct #python
print("hi ") name = input("enter name: ") age = input("enter age: ") if(age => 18): print("welcome") # go to print("oi") else: print("too young") # go back to age = input("...")) print("oi") I am new to coding and i really dont know what to do here. I use this app to save and try later on a pc. Can somebody help me please?
2 Answers
+ 4
You can use an infinite loop and only break the loop if a valid age is entered:
print("hi ")
name = input("enter name: ")
while True:
age = int(input("enter age: "))
if(age >= 18):
print("welcome")
break
# go to print("oi")
else:
print("too young")
# go back to age = input("..."))
print("oi")
+ 1
thanks a lot Anna i can go on trying now đ