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

Re: [pygame] Break outside the loop



Joseph king 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
I'm not really too clear on what's happening here.
You can use break to get out of for loops, can't you?
Shouldn't this just be a logical error, and just get hung in the while loop (since it has no exit condition)? Or is the problem that the 'while 1' is tabbed over slightly less than the inner 'for x in range(8)' which is somehow causing
it to be outside of the outer for loop, or something?
I'd appreciate it if someone could explain that.
-Luke