3

它告诉我我在第 19 行的报价单上有一个无效的语法: year = int(input("Enter year: ")) while (year < 1900 or year > 2100): print"Error out of range. Please re-输入”

我真的不知道它是什么。它说它在引号周围,但缩进似乎很好,括号也是。我在那里尝试了一切,但我不知道

我的程序:

def isLeapYear(year):

    if year % 400 == 0:
        return True
    elif year % 100 == 0:
        return False
    elif year % 4 ==0:
        return True
    else:
        return False

def conversion(month):
    conversionmonth = (month + 10) % 12
    return conversionmonth

def main():

    year = int(input("Enter year: "))
     while (year < 1900 or year > 2100):
     print"Error out of range. Please re-input"
     year = int(input("Enter year: "))
    if isLeapYear(year):
     print "is a leap year"
    else:
     print "is not a leap year"


    month = int(input("Enter month: "))
    month = conversion(month)
     while (month < 1 or month > 12)
      print "Error out of range. Please re-input"
       month = int(input("Enter month: ")

    day = int(input("Enter day: "))
     while (day < 1 or input > 31)
      if month == February and day > 29:
       print "Error out of range. Please re-input"
        day = int(input("Enter day: ")
        if isLeapYear and day > 28:
         print "Error out of range. Please re-input"
          day = int(input("Enter day: ")
     print "Error out of range. Please re-input"
      day = int(input("Enter day: ")

    a = month
    b = day
    c = year
    d = year // 100
    w = (13 * a - 1) // 5
    x = c // 4
    y = d // 4
    z = w + x + y + b + c - 2 * d
    r = z % 7
    r = (r + 7) % 7
     if (r == 0):
      print "Sunday"
     if (r == 1):
      print "Monday"
     if (r == 2):
      print "Tuesday"
     if (r == 3):
      print "Wednesday"
     if (r == 4):
      print "Thursday"
     if (r == 5):
      print "Friday"
     if (r == 6):
      print "Saturday"

main()
4

1 回答 1

2

在 Python 3 中,print是一个函数,你必须用类似的东西来调用它

print("Error out of range. Please re-input")
于 2013-07-04T02:06:48.673 回答