title: Jupyter input, display, print execution order is chaotic
body: <p>I'm using Jupyter and my Python version is 3.5. In my <code>while</code> loop, execution order is not correct; the <code>input</code> from one iteration is shown <em>before</em> the final <code>print</code> of the previous iteration. This is my code.</p>
  <pre><code>from IPython.display import display
  import pandas as pd
  df = pd.DataFrame({'a':[1,2],'b':[3,4]})
  while(True):
      a = input(&quot;please input:\n&quot;)
      display(df.head())
      print (a)
  </code></pre>
  <p>The execution result is
  <a href="https://i.stack.imgur.com/KpzAv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KpzAv.png" alt="screenshot of execution" /></a></p>