【发布时间】:2017-12-01 06:36:42
【问题描述】:
由于我是一个完全的编程新手,我需要您对我需要完成在线课程的编码练习提出建议。
这里是指令:
mystery_int_1 = 3
mystery_int_2 = 4
mystery_int_3 = 5
(这些在我提交代码后会改变,所以只是一个例子)
以上是三个值。运行 while 循环,直到所有三个值都小于或等于 0。每次更改三个变量的值时,都在同一行打印出它们的新值,用单个空格分隔。例如,如果它们的值分别为 3、4 和 5,您的代码将打印:
2 3 4
1 2 3
0 1 2
-1 0 1
-2 -1 0
我试过这样写:
while not mystery_int_1 <= 0 and not mystery_int_2 <= 0 and not mystery_int_3 <= 0:
mystery_int_1 -= 1
mystery_int_2 -= 1
mystery_int_3 -= 1
print(mystery_int_1, mystery_int_2, mystery_int_3)
运行代码后,我意识到它有问题,但我不知道如何修改它。尝试了许多选项,但它们都没有按预期工作......
提前谢谢大家!
【问题讨论】:
-
发布带有输出和预期输出的完整代码
标签: python python-3.x debugging while-loop