I have been researching for quite a while on this, and I can't figure out what is wrong. I am rather new to Python is general, so it probably an easy fix.
def main():
age = 0;
weight = 0;
birthMonth = " ";
getAge();
getWeight();
getBirth();
correct();
def getAge():
age = input("Guess the age.\t")
return age;
def getWeight():
weight = input("Guess the weight.\t")
return weight;
def getBirth():
birthMonth = input("Guess the month.\t")
return birthMonth;
def correct():
if (age <= 25):
print ("Congratulations, the age is 25 or less")
else:
print ("You did not correctly guess the age");
if (weight <= 128):
print ("Congratulations, the weight is 128 or more")
else:
print ("You did not correctly guess the weight");
if (birthMonth == 25):
print ("Congratulations, the month is April")
else:
print ("You did not correctly guess the month");
main();
The error I get after running it in Idle is the and answering three prompts is the following:
Traceback (most recent call last):
line 39, in <module>
main();
line 9, in main
correct();
line 24, in correct
if (age <= 25):
NameError: name 'age' is not defined
Please help, or send me to a post that will help. I tried to find something like this for around an hour.