<br><br><div class="gmail_quote">On 23 May 2012 15:21, Bala subramanian <span dir="ltr">&lt;<a href="mailto:bala.biophysics@gmail.com" target="_blank">bala.biophysics@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Friends,<br>While iterating through each list item and printing/writing it, why does the sq. brackets get printed/written to the file. Just a small eg.code is given below. <br><br>&gt;&gt;&gt;N=100<br>&gt;&gt;&gt; myl=range(1,100+1)<br>


&gt;&gt;&gt; new=[myl[i:i+15] for i in range(0, len(myl),15)]<br>&gt;&gt;&gt; for x in new: print x<br><br></blockquote><div><br></div><div><div>When you slice &#39;myl[i:i+15]&#39; you are creating a new list and adding that to &#39;new&#39;. So essentially you are nesting new lists within a list comprehension.</div>

<div><br></div><div>Hope that helps!</div></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks,<br>Bala<br><br><br><br>
<br>_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>An monkey typed up this email. Please excuse him if he made a stupid error!<br>