title: How can I stop a While loop?
body: <p>I wrote a <code>while loop</code> in a function, but don't know how to stop it. When it doesn't meet its final condition, the loop just go for ever. How can I stop it?</p>
  
  <pre><code>def determine_period(universe_array):
      period=0
      tmp=universe_array
      while True:
          tmp=apply_rules(tmp)#aplly_rules is a another function
          period+=1
          if numpy.array_equal(tmp,universe_array) is True:
              break    #i want the loop to stop and return 0 if the 
                       #period is bigger than 12
          if period&gt;12:  #i wrote this line to stop it..but seems it 
                         #doesnt work....help..
              return 0
          else:   
              return period
  </code></pre>