语法错误
请各位前辈解答,这里为啥报语法错误? temp = input ("请输入一个年份")while not temp.isdigit():
temp = input ("输入有误,请输入一个整数")
year = int(temp)
if year/400 ==int(year/400):
print (temp + "是闰年!")
else:
if(year/4 == int(year/4)and(year/100!=int(year/100)
print(temp + "是闰年!")
else:
print (temp +"不是闰年!")
杨根荣 发表于 2022-6-5 12:21
把错误信息也贴出来 09行的 if 后面少了一个冒号(:) print (temp + "是闰年!")改成
print(temp + "是闰年!")
if(year/4 == int(year/4)and(year/100!=int(year/100)改成
if ( year/4 == int(year/4) ) and ( year/100 != int(year/100) ): 参考代码:temp = input("请输入一个年份")
while not temp.isdigit():
temp = input("输入有误,请输入一个整数")
year = int(temp)
if year / 400 == int(year / 400):
print(temp + "是闰年!")
else:
if (year / 4 == int(year / 4)) and (year / 100 != int(year / 100)):
print(temp + "是闰年!")
else:
print(temp + "不是闰年!") liuzhengyuan 发表于 2022-6-5 12:24
09行的 if 后面少了一个冒号(:)
temp = input ("请输入一个年份")
while not temp.isdigit():
temp = input ("输入有误,请输入一个整数")
year = int(temp)
if year/400 ==int(year/400):
print (temp + "是闰年!")
else:
if(year/4 == int(year/4)and(year/100!=int(year/100):
print(temp + "是闰年!")
else:
print(temp +"不是闰年!")
加上也显示invalidsyntax
页:
[1]