Hello There,
I am a beginner python developer. I made a simple python3 code which have three case.
- if age = less than 18 then print you cannot drive
- when age = 18 print we will think about you
-
when age = more than 18 you can drive
- and if the input or age = more than 100 then it should print invalid age
and this program works very well but if i use nested if else statement it doesn't work here is the code :
age calculator for driving
print()
print("\t Age requirement for Driving")
age = int(input(" Enter Your Age : "))
if age < 18:
print(" Sorry, You're under age. You cannot drive")
elif age == 18:
print(" Sorry, we cannot Decide. we will think about you :) ")
elif age > 100:
print(" Invalid Age !!! Your are not immortal ;)")
else:
print(" Congratulation !!! You can Drive")
Code with Nested if else statement
print()
print("\t Age requirement for Driving")
age = int(input(" Enter Your Age : "))
if age < 18:
print(" Sorry, You're under age. You cannot drive")
if age > 100:
print(" Invalid Age")
elif age == 18:
print(" Sorry, we cannot Decide. we will think about you :) ")
else:
print(" Congratulation !!! You can Drive")
this code doesn't work please help !!!
Aucun commentaire:
Enregistrer un commentaire