[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Break outside the loop





On Nov 14, 2007 9:52 PM, Joseph king <king.a.joe@xxxxxxxxx> wrote:
I keep getting a ***'break' outside the loop error on this code can anyone help


 for y in range(8):
    for x in range(8):
      c = Canvas()
      c.grid(column=x, row=y)
   # make a grid
      grid = Grid(c, cellsize_x=8, cellsize_y=8, gridsize_x=10, gridsize_y=10)
   # get the maze generator
      explorer = MazeBuilder(grid)

   while 1:
     grid.update()
   try:
     explorer.next ()

   except StopIteration:
       break
c.mainloop()

From what I can gather, it looks as if you wanted
while 1:
    grid.update()
    try:
        explorer.next()
    except StopIteration:
        break

with try/except in the while loop?  As you have it, the break is outside of the loop.