每月用户输入

时间:2016-07-15 14:13:23

标签: python-3.x

我正在尝试让用户输入相关月份的正确日期,例如没有好的进入二月30,或六月31。这是我的代码,但我不断收到elif语句的语法错误。那是为什么?

if month == ('February') and (LeapYear == False):
        maxday == 28
if month == ('February') and (LeapYear == True):
        maxday == 29
if month == ('April') or ('June') or ('September') or ('November'):
        maxday == 30
else:
        maxday == 31 
while True:
        which_day = int(input("Enter a positive number, 1 to 31 or to quit: "))
        if which_day < 0 or which_day > maxday:
                print("day for month incorrect - try again..please!")
                continue
elif which_day <= maxday:
        print("OK, we can go from here...!")
        print (maxday , which_day)
        break
print("All done!")

0 个答案:

没有答案