title: How to interrupt a python program?
body: <p>I have made a program that essentially runs a loop like so:</p>
  <pre class="lang-py prettyprint-override"><code>while(true):
      i = 0
      while(i &lt; 60):
          i += 1
          time.sleep(1)
  </code></pre>
  <p>I would like to be able to pause it while it is running and go back to it (keeping the <code>i</code> as it was when interrupted) . Currently the program has nothing to do with taking an input from the user and it just runs in the background. Is there a way to pause a running script in a way that will keep the code at the same state that it was when I paused it and be able to continue from that point?
  The program runs either on pycharm or normal Python 2.7 through the cmd.<br />
  (I have some basic knowledge of key logging and thread usage. So if that will work I am willing to try it out).</p>