num = int(input()) for i in range(num-1): # to get diamond corners peak we have done num - 1 for j in range(i,num): # "space" decreasing triangle print(" " , end=" ") for j in range(i): # " * " increasing triangle print("*" , end=" ") for j in range(i+1): # " * " increasing triangle print("*" , end=" ") print() for i in range(num): for j in range(i+1): #empty increasing triangle print(" " , end=" ") for j in range(i, num-1): # " * " decreasing triangle & here in this line (num - 1) is for edge print("*" , end=" ") for j in range(i, num): # " * " decreasing triangle print("*" , end=" ") print()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter