title: Nested loops where inner loop variable depends on outer loop variable, Python
body: <p>In Java, if I want to create nested loops where the inner loop variable depends on the outer loop variable (e.g. in typical bubble sort implementations), I can do something like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>for(int i=0; i &lt; n; i++){
       for(int j=i; j &lt; n; j++){
           // Do something, e.g compare elements at index i and j
       }
  }
  </code></pre>
  
  <p>What's the most "Pythonic" way to accomplish this in Python? I'm having trouble when I try to set the inner loop variable to the outer loop variable. For example, this doesn't work:</p>
  
  <pre><code>for i in range(n):
       for j=i in range(n):
           # Do something, e.g compare elements at index i and j
  </code></pre>