我正在做一个程序来计算给定的输入是否是闰年。我正在Windows10上使用Python2.7和AnacondaShell。 这是一个愚蠢的程序,我不明白为什么我得到这个错误。有一对夫妇的解决方案,这个特定的程序在线,但我想让我的版本工作。请帮帮我!你知道吗
我收到错误消息“TypeError:'int'object is not iterable” 我试着在谷歌上搜索一些东西,看看以前的答案,但我很困惑!你知道吗
def sort_year(user_input):
for i,j in range(0,9):
if user_input == [ij00]:
leap_yr1(user_input)
else:
leap_yr2(user_input)
def leap_yr1(user_input):
if user_input % 400 == 0:
print("The given year is a leap year")
else:
print("The given year is not a leap year")
def leap_yr2(user_input):
if user_input % 4 == 0:
print("The given year is a leap year")
else:
print("The given year is not a leap year")
print("Which year do you want to check?: ")
user_input = int(raw_input())
sort_year(user_input)
我想你应该试着写作
但是我想你应该检查一下
user_input
中的最后两个数字,这样你就不需要for
。你知道吗如果
number
结尾有00
,那么number % 100 == 0
(这里%
表示函数modulo
)相关问题 更多 >
编程相关推荐