Flip lines to form a diamond in python 3

Change your second while loop to check if star <= height, and increment star from 2.

So it would look something like

star = 2
while star <= height:
    a = int(star)
    b = int(2*height-2*star)
    c = int((height-star))
    d = int(star)
    print(a*'*', b*' ',c*'',d*'*',sep='')
    star = star + 1

This is because you want to go from “small” to “large” so you need to do the inverse of the first while loop which decrements the amount of *‘s.

Leave a Comment