Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Variable Issue
#1
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
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable scope issue melvin13 2 1,506 Nov-29-2021, 08:26 PM
Last Post: melvin13
  Issue with affecting numbers to a variable Adem 3 2,247 Sep-24-2019, 07:48 AM
Last Post: Adem
  Mixed string,Integer input variable issue maderdash 2 2,712 Nov-06-2018, 09:46 AM
Last Post: snippsat
  Variable Resetting Issue Niicollas__ 8 4,169 Jan-20-2018, 08:52 PM
Last Post: j.crater
  netCDF issue with filling a variable HeavyLoads 1 11,265 Oct-03-2016, 08:34 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020