Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Variable Issue
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.')
   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.

ichabod801 wrote Nov-09-2019, 04:25 PM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.
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 -
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

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.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Issue with affecting numbers to a variable Adem 3 337 Sep-24-2019, 07:48 AM
Last Post: Adem
  Mixed string,Integer input variable issue maderdash 2 642 Nov-06-2018, 09:46 AM
Last Post: snippsat
  Variable Resetting Issue Niicollas__ 8 1,348 Jan-20-2018, 08:52 PM
Last Post: j.crater
  netCDF issue with filling a variable HeavyLoads 1 1,995 Oct-03-2016, 08:34 PM
Last Post: micseydel

Forum Jump:

Users browsing this thread: 1 Guest(s)