how to iterate in a string in python?
<p>I want to make some montage in <code>ImageMagick</code> which is called by Python via <code>os.system()</code> with 100 jpegs files.</p>

<p>Here's the command:</p>

<pre><code>cmd='montage '+file[i]+' '+file[i+1]+' '+file[i+2]+' '+file[u+3]+'     +file[i+4]+'...+file[i+99]
</code></pre>

<p>I would like to know how could I avoid to write all <code>file[i+x]</code> entries.
Is this possible?</p>

<p>To join 100 strings with a space starting at <code>i</code>th index:</p>

<pre><code>cmd = "montage " + " ".join(file[i:i+100])
</code></pre>

<p>.. where <code>file[i:i+100]</code> will return a sub-sequence starting at i, and ending at (i + 100 - 1)</p>

python