在 python 中制作图案

Making a pattern in python

我不知道如何在 python 中使用循环,需要帮助来制作这个模式:

*
**
***
**** 
***** 

这是我试过的:

for x in range(0, 5):
  print ("*")    

结果是:

*
*
*
*
*

这是一个分步解决方案。

# for loop
for cnt in range(1,6):
    # print 'cnt' number of asterisks
    print(cnt * '*')

结果是:

*
**
***
****
*****