我正在尝试制作一个看起来像这样的三角形
1 12 123 1234 12345
这段代码使它一遍又一遍地打印1
def line(n):
print('1' *n)
def triangle(n):
for i in range(1,n+1):
line(i)
怎么样(假设Python 3):
def line(n):
for i in range(n):
print(i+1, end='')
print()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句