我試圖生成一個100個三角形數字的列表。這是我生成100個三角形數字的原因。當我運行它時,我得到100個列表,如何將它更改爲用100個元素生成一個列表?用多個元素生成一個列表
def Triangular():
n=0
while n<101:
n=1+n
triangleNumbers = (n*(n+1))//2
print ([triangleNumbers])
Triangular()
Desired Result: [1,3,6,..]
Actual Result:
[1]
[3]
[6]
[10]
[15]
[21]
[28]
...