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?

19th Oct 2018, 8:33 PM
kenny desmit
2 Antworten
+ 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")
19th Oct 2018, 8:53 PM
Anna
Anna - avatar
+ 1
thanks a lot Anna i can go on trying now 😀
20th Oct 2018, 9:28 AM
kenny desmit