title: Why can't I print every outcome in for-loop?
body: <pre><code>strs = [&quot;flower&quot;,&quot;flow&quot;,&quot;flight&quot;,&quot;fluea&quot;,&quot;flfjdkl&quot;,&quot;f&quot;]
  temp = strs[0]
  
  for i in range(1, len(strs)):
      for j in range(len(temp)):
          if j &gt;= len(strs[i]) or strs[i][j] != temp[j]:
              temp = temp[:j]
              print(temp)
              break
  </code></pre>
  <p>I want to print variable <code>temp</code> whenever it finishes <code>if</code> statement.
  However, it will only print whenever <code>temp</code> changes.</p>
  <p>For example, the outcome of this code is:</p>
  <pre><code>flow
  fl
  f
  </code></pre>
  <p>But I want the result to be:</p>
  <pre><code>flow
  fl
  fl
  fl
  f
  </code></pre>