<p>If I'm making a simple grid based game, for example, I might have a few 2d lists. One might be for terrain, another might be for objects, etc. Unfortunately, when I need to iterate over the lists and have the contents of a square in one list affect part of another list, I have to do something like this.</p>

<pre><code>for i in range(len(alist)):
    for j in range(len(alist[i])):
        if alist[i][j].isWhatever:
            blist[i][j].doSomething()
</code></pre>

<p>Is there a nicer way to do something like this?</p>

```
```
for d1 in alist
   for d2 in d1
      if d2 = "whatever"
          do_my_thing()
```
```