나는 그것이 어리석은 것을 알고 있지만 왜 작동하지 않는지 알 수 없습니다. 도와주세요.NameError : name 'April'이 정의되지 않았습니다.
def main():
yourAge=getAge() #get subject's age
yourWeight=getWeight() #get subject's weight
yourBirthMonth=getMonth() #get subject's birth month
correctAnswers(getAge, getWeight, getMonth)
def getAge():
yourAge=input('Enter your age. ')
return yourAge
def getWeight():
yourWeight=input('Enter your weight.')
return yourWeight
def getMonth():
yourBirthMonth=input('Enter your birth month. ')
return yourBirthMonth
def correctAnswers(getAge, getWeight, getMonth):
if getAge <= 25:
print'Congratulations, age is less than 25.'
if getWeight >= 128:
print'Congratulations, weight is more than 128.'
if getMonth == 'April':
print'Congratulations, month is April.'
main()
역 추적 : python2 input
에서
Traceback (most recent call last):
File "C:/Users/Beth/Documents/jeff/prog/lab 03/lab 3-5.py", line 35, in <module>
main()
File "C:/Users/Beth/Documents/jeff/prog/lab 03/lab 3-5.py", line 10, in main
yourBirthMonth=getMonth()#get subject's birth month
File "C:/Users/Beth/Documents/jeff/prog/lab 03/lab 3-5.py", line 22, in getMonth
yourBirthMonth=input('Enter your birth month. ')
File "<string>", line 1, in <module>
NameError: name 'April' is not defined
로 입력을 실행하려고
바꾸기이 파이썬인가 2.7 또는 3.x? – IanAuld