Why is the Welcome output if less than 18? | Sololearn: Learn to code for FREE!


Why is the Welcome output if less than 18?

age = int(input()) name = input("Welcome ") if age >= 18: print(name) else: print ("Sorry")

1/29/2021 2:11:50 PM


5 Answers

New Answer


Coz the input stmt is not inside if or else ,so whatever be the condition , it outputs "Welcome "... You can try this : age =int(input()) if age>=18 : name=input("Welcome") print(name) else : print ("Sorry")


"Welcome" is a text displayed when the input dialogue pops up (you cannot see this on sololearn, but you will notice the difference whe you run it locally on your pc). It is NOT parte if the value of name


Because 18 is the age required or that satisfy condition to not accept person less than 18 years old.


age =int( input()) if age>=18: name =input ("Welcome") print(name) else : print ("Sorry") You can try it. I think it will helps.