0
Why is the Welcome output if less than 18?
age = int(input()) name = input("Welcome ") if age >= 18: print(name) else: print ("Sorry")
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")
+ 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
+ 2
Because 18 is the age required or that satisfy condition to not accept person less than 18 years old.
+ 1
age =int( input())
if age>=18:
name =input ("Welcome")
print(name)
else :
print ("Sorry")
You can try it.
I think it will helps.
0
thanksđđ