z=1   

 while z<=40:

 y=0
 x=10
while y<=10:
    print(" "*y,"*")
    y+=1
while x>=0:
    print(" "*x,"*")
    x-=1
    z=z+1

You can use he same variable for the number of spaces to print, see below. If you want to print a total of 40 stars, I can't tell from your code and you didn't explain

empty_spaces=0
one_side=7 # stars
stars_side=0
incr=1
stars_printed=0
while stars_printed < 40:
    print "%s*" % (" "*empty_spaces)
    stars_printed += 1
    empty_spaces += incr
    stars_side += 1

    ## change direction every "one_side" stars
    if stars_side >= one_side:
        stars_side=0
        if incr == 1:
            incr = -1
            print "testing: incr changed to minus one"
        else:
            incr = 1
            print "testing: incr changed to plus one"

Edited 2 Years Ago by woooee

This question has already been answered. Start a new discussion instead.