我很难找出如何停止代码中的循环:
def shampoo_instructions(num_cycles):
for num_cycles in range(1,num_cycles+1):
if num_cycles < 1:
print 'Too few.'
elif num_cycles > 4:
print 'Too many.'
else:
print num_cycles, ': Lather and rinse.'
else:
print 'Done.'
shampoo_instructions(2)
我的输出将是:
1 : Lather and rinse.
2 : Lather and rinse.
Done.
洗发水时如何做到这一点(6)
只是印的太多了
是吗?在
移动你的范围检查,以超出你的实际循环,例如:
相关问题 更多 >
编程相关推荐