mercredi 3 mars 2021

How to stop this from repeating?

Im currently in a begginers python class so dont bash too hard.... but im doing text patterns based on randomly generated numbers and currently am facing an issue I cant figure out

if random_num > 0:
        for j in range(random_num):
            for i in range(random_num):
                print("*"*(random_num-i))
            print()

that is a the part of my code that creates a triangle pattern based off of a random number thats already generated. My results from running this is :

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"

Aucun commentaire:

Enregistrer un commentaire