0

Can anyone help me to find out the real problem in this source code.

num = 59 if num <= 17: print("you are a child and not a voter") elif num >= 18: print("you are a voter and you must vote for you country") else: print("you are dead")

8th Nov 2018, 11:22 AM
Krishna Ramdam
Krishna Ramdam - avatar
3 Answers
+ 8
Your indentations are off. It should look like num = 59 if num <= 17: print("you are a child and not a voter") elif num >= 18: print("you are a voter and you must vote for you country") else: print("you are dead") Moreover, assuming num is an integer, it'll always be either <=17 or >=18. So the "else" block would never really execute. Maybe instead of elif num>=18, you could do something like elif 18<= num <= 122: Then whenever someone uses a num bigger than 122 (age of the verified oldest person ever lived, according to wiki), your code would call them dead. 😅
8th Nov 2018, 11:26 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 3
You're welcome :)
16th Nov 2018, 11:10 AM
Kishalaya Saha
Kishalaya Saha - avatar
0
I don't know much about indentation back then. Thanks for helping.
16th Nov 2018, 10:52 AM
Krishna Ramdam
Krishna Ramdam - avatar