我目前在初学者 python 类中,所以不要太用力....但是我根据随机生成的数字做文本模式,目前面临一个我无法弄清楚的问题
if random_num > 0:
for j in range(random_num):
for i in range(random_num):
print("*"*(random_num-i))
print()
这是我的代码的一部分,它根据已经生成的随机数创建三角形图案。我运行的结果是:
Do you wish to print another pattern (y/n)? y
Random Number: 4
****
***
**
*
****
***
**
*
****
***
**
*
****
***
**
*
````````````````````````````````````````````````````````````````````````````````````````````````````````
it prints the triangle how I want it by taking one off after every row but as you can see it prints itself same amount of times as number generated. anyone have any imput? also I cannot use "break"