vendredi 10 janvier 2020

Print a Complex Diamond Pattern of pattern

I am trying to build a diamond pattern of diamond pattern. Let me break it down for you. Currently I have a function that prints a diamond pattern with input as size.

def diamond(n,space=' '): 

    for i in range(n):
        print(space*(n-1-i) + "* "*(i+1))            
    for l in range(n-1,0,-1):   
        print(space*(n-l) + "* "*(l))

diamond(2)

My output will be a diamond of size 2

 * 
* * 
 * 

Now what i really what is replace each star with this diamond pattern itself. Desired output to look like.

enter image description here

Should be able to do this for all sizes, where each star of that pattern is replaced by the whole pattern.

Thank you.

Aucun commentaire:

Enregistrer un commentaire