代码不起作用。问题提示: 松鼠聚会时,喜欢抽雪茄。当雪茄数量在40到60支(含)之间时,松鼠派对是成功的。除非是周末,在这种情况下,雪茄数量没有上限。如果具有给定值的一方成功,则返回True,否则返回False。你知道吗
def cigar_party(cigars, is_weekend):
if is_weekend:
if cigars > 40:
return True
else:
return False
else:
if cigars >= 40 and cigars <= 60:
return True
else:
return False
cigar_party(30, False) → False False OK
cigar_party(50, False) → True True OK
cigar_party(70, True) → True True OK
cigar_party(30, True) → False False OK
cigar_party(50, True) → True True OK
cigar_party(60, False) → True True OK
cigar_party(61, False) → False False OK
cigar_party(40, False) → True True OK
cigar_party(39, False) → False False OK
cigar_party(40, True) → True False X
cigar_party(39, True) → False False OK
other tests
OK
在第一个if语句下,if cigars>;40:cannot=40。下面的代码将正常工作
相关问题 更多 >
编程相关推荐