title: Breaking out of nested loops
body: <p>Is there an easier way to break out of nested loops than throwing an exception? (In <a href="https://en.wikipedia.org/wiki/Perl" rel="noreferrer">Perl</a>, you can give labels to each loop and at least continue an outer loop.)</p>
  <pre><code>for x in range(10):
      for y in range(10):
          print x*y
          if x*y &gt; 50:
              &quot;break both loops&quot;
  </code></pre>
  <p>I.e., is there a nicer way than:</p>
  <pre><code>class BreakIt(Exception): pass
  
  try:
      for x in range(10):
          for y in range(10):
              print x*y
              if x*y &gt; 50:
                  raise BreakIt
  except BreakIt:
      pass
  </code></pre>