所以,对于下面我得到:return century == year // 100 + 1 or century == year / 100
但是,我不满意最后一个:
>>>in_century(2013, 20)
False
如果世纪恰好等于年份除以 100,我该如何做到这一点?另外,表达式的格式或多或少是正确的吗?
谢谢!
这是问题:
def in_century(year, century):
'''(int, int) -> bool
Return True iff year is in century.
Remember, for example, that 1900 is the last year of the 19th century,
not the beginning of the 20th.
year will be at least 1.
>>> in_century(1994, 20)
True
>>> in_century(1900, 19)
True
>>> in_century(2013, 20)
False
'''