title: should i use for loop or while loop to make a break timer in python?
body: <p>I have this code to stop a function at a specific time. I would loop through the function and then break the function, if it takes too long, is there a better way to do it?</p>
  <pre class="lang-py prettyprint-override"><code>import time
  
  def function_one()    
      rec = (time.time())
      print(&quot;im starting&quot;)
      ans = str(time.time() - rec)
      ans = (round(float(ans), 15))
      print(&quot;this is where im doing something code&quot;)
      while ans &lt; 10:
            return function_one()
            break
  </code></pre>