0
我需要使用嵌套循環來產生三角形。輸出需要看起來像這樣。嵌套循環產生三角形,錯誤的方式
How many lines? 7
0000000
000000
00000
0000
000
00
0
目前我試圖使用這個,但我不確定如何讓0面對正確的方式。
def main():
start = int(input("How many lines?"))
end = 0
increment = -1
for rows in range(start,end,increment):
for colums in range(rows):
print("0", end= "")
print()
main()
而這個的輸出是。
How many lines?7
0000000
000000
00000
0000
000
00
0
我只是不確定如何解決它,任何幫助表示讚賞。
的可能的複製[Python的:打印星號的三角形圖案(http://stackoverflow.com/questions/26352412/python-print-a-triangular-pattern-of-asterisks) – trincot