我正在尝试制作一个将打印以下内容的python程序:
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
这是我为解决此问题而编写的代码,但是我不知道为什么它不起作用。就像程序完全忽略“ for range in n(10)”这一行一样
value = 0
for n in range(10):
if value < 10:
print(value, " ", end="", flush=True)
value += 1
你可以这样做:
for n in range(11):
for i in range(n):
print(i, end=" ")
print()
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句