Python Forum

Full Version: Variable Issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello - I'm very new to python and working on a simple voting program where it asks what the user's age is. If they are 18 or older it will print "You're of voting age. If they're not 18, it will print "You must be 18 to vote. See my code below.
voter_age = int(input('How old are you?'))
If voter_age <= 18:
    Print ('You are of voting age.')
else:
   Print('You must be 18 to vote.')
There is something wrong with my variable voter_age. I get an error on line 2 when I run the program. Any help is appreciated.

Slackerman
If and Print should not be capitalized. Python is case sensitive. Most of the base Python functions and statements will be lowercase.

Also, check you indentation on line 5. Whatever indentation you use, it should be consistent throughout the program.
That was it! OMG, I can't believe it. I sat here looking at that for over 20 minutes and couldn't find anything wrong with what I had written. I'll definitely keep on the lookout for case in the future. Thanks so much.