I'm new to Python programming and I'm stuck with the following error:
form="""
<form method="post">
What is your birthday?
<br>
<label> Month
<input type="text" name="month">
</label
<label> Day
<input type="text" name="day">
</label>
<label> Year
<input type="text" name="year">
</label>
<br>
<br>
<input type="submit">
</form>
"""
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.out.write(form)
def valid_day(day):
if day and day.isdigit():
day = int(day)
if day > 0 and day <= 31:
return day
def valid_year(year):
if year and year.isdigit():
year = int(year)
if year > 1899 and year < 2021:
return year
def post(self):
user_day = valid_day(self.request.get('day'))
user_year = valid_year(self.request.get('year'))
I'm told that global name 'valid_day' is not defined. Can anybody tell me where is the fault? I think I defined the function valid_day / valid_year above so it should be accessible, or not?