dimanche 5 décembre 2021

How to print pyramid in python - verification

I have a little slight confusion , below pattern is printed by adding 3 spaces with '* '. Is it a right approach to do ?

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

Code :

for row in range(1,5+1):
  print(' ' * (5-row)*2 + row * '*   ')

Or i need to follow any different approach to print it. Suggest me some other approach ?

Aucun commentaire:

Enregistrer un commentaire