*
  *
   *
    *
     *
      *
       *
       *
      *
     *
    *
   *
  *
 *
*
 *
  *
   *
    *
     *
      *
       *
 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

IndentationError: unexpected indent

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"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.