mercredi 14 avril 2021

Printing Pattern Horizontally in Python

So I have to print * in the shape of A which I did.

pattern = ""
for row in range(7):
      for col in range(5):
            if ((col==0 or col==4) and row!=0) or ((row==0 or row==3) and (col>0 and col<4)):
                  pattern = pattern + "*"
            else:
                  pattern = pattern + " " 
      pattern = pattern + "\n"
pattern = pattern + " "

print(pattern, end="")

OUTPUT:

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

But I want to print more A horizontally. Example: L displayed as star program 3 times looks as below

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

Please help!

Aucun commentaire:

Enregistrer un commentaire