python if else 1

python if else


print('What is age?')
age = int(input('number:')) # user gives number as input
if age > 18:
    print('go ahead drive')
elif age == 18:
    print('come personaly for test')
    print('still underage')

Here is what the above code is Doing:
1. It’s asking the user to input their age.
2. It’s converting the input to an integer.
3. It’s checking if the age is greater than 18.
4. If it is, it prints “go ahead drive”.
5. If it’s not, it checks if the age is equal to 18.
6. If it is, it prints “come personaly for test”.
7. If it’s not, it prints “still underage”.

Similar Posts