|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
read = 0
yellow = 0
green = 0
while read <= 3:
while yellow <= 3:
while green <= 6:
if read + yellow + green == 8:
print('红色球为 %d、蓝色球为 %d、绿色球为 %d。' % (read, yellow, green), end='')
green += 1
else:
green += 1
yellow += 1
read += 1
每次循环要重新初始化
yellow = 0
green = 0
还有你read 缩进要多打一个
正确代码:read = 0
while read <= 3:
yellow = 0
while yellow <= 3:
green = 0
while green <= 6:
if read + yellow + green == 8:
print('红色球为 %d、蓝色球为 %d、绿色球为 %d。' % (read, yellow, green))
green += 1
else:
green += 1
yellow += 1
read += 1
|
|