0

Why is the Welcome output if less than 18?

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

29th Jan 2021, 2:11 PM
Evgeny
Evgeny - avatar
5 RĂ©ponses
+ 5
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")
29th Jan 2021, 2:15 PM
Alphin K Sajan
Alphin K Sajan - avatar
+ 3
"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
29th Jan 2021, 2:18 PM
Lisa
Lisa - avatar
+ 2
Because 18 is the age required or that satisfy condition to not accept person less than 18 years old.
29th Jan 2021, 2:21 PM
HBhZ_C
HBhZ_C - avatar
+ 1
age =int( input()) if age>=18: name =input ("Welcome") print(name) else : print ("Sorry") You can try it. I think it will helps.
30th Jan 2021, 11:47 PM
â€ïžđŸ˜PreranađŸ˜â€ïž
â€ïžđŸ˜PreranađŸ˜â€ïž - avatar
0
thanks👍😊
29th Jan 2021, 2:20 PM
Evgeny
Evgeny - avatar