<div>On Sat, Sep 25, 2010 at 9:40 AM, Evert Rol <span dir="ltr">&lt;<a href="mailto:evert.rol@gmail.com">evert.rol@gmail.com</a>&gt;</span> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">&gt; any one have an idea about how we can input many number in the one time and change it to list.<br>
&gt; for example:<br>
&gt;<br>
&gt; a=input(&quot;Enter the number of your class in the school:&quot;)     # the number can be enter as: 12,13,14 or 12 13 14 with a space in between.<br>
&gt;<br>
&gt; now how I can put these numbers into list like b=[12,13,14] with len( a ) =3<br>
<br>
</div>A string has a method split(); that may help you.<br>
In your case, where you want either a space or a comma as a separator, it depends whether both can be used at the same time. If not, you can check for the occurrence of one or the other separator and run split() with the correct separator. If both can occur in the same line, you may want to use the regex module instead: re.split()<br>

</blockquote><div><br></div><div>No need for the &#39;re&#39; module. Even in the case where both can be used together, you can still just use string methods: </div><div><br></div><div>&gt;&gt;&gt; s</div><div>&#39;12, 13 14&#39;</div>

<div>&gt;&gt;&gt; s.replace(&#39;,&#39;, &#39;&#39;).split(&#39; &#39;)</div><div>[&#39;12&#39;, &#39;13&#39;, &#39;14&#39;]</div><div><br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<br>
hth,<br>
<br>
  Evert<br>
<div class="im"><br>
<br>
&gt; I tried with that but it&#39;s working only for a numbers less than 10 ex. 1,2,3 or 1 2 3 but it&#39;s not when I go for numbers higher than 10 like in example above.<br>
&gt;<br>
&gt; a=raw_input(&quot;Enter the number of your class in the school:&quot;)<br>
&gt; m=[]<br>
&gt;  for I range (len( a)):<br>
&gt;     if a[I]==&#39;,&#39;:<br>
&gt;         pass<br>
&gt;     elif a[I]==&#39; &#39;:<br>
&gt;         pass<br>
&gt;     else:<br>
&gt;         m.append(a[I])<br>
&gt; m=map(float,m)<br>
&gt; print m;print len( m )<br>
&gt; &gt;&gt; [1,2,3]<br>
&gt; &gt;&gt; 3<br>
&gt;<br>
&gt; looking forward to seeing your help,<br>
&gt; regards,<br>
&gt; Ahmed<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div>&gt; _______________________________________________<br>
&gt; Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
&gt; To unsubscribe or change subscription options:<br>
&gt; <a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><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>
</blockquote></div><br><br clear="all"><br>-- <br>Brian K. Jones<br>My Blog          <a href="http://www.protocolostomy.com">http://www.protocolostomy.com</a><br>Follow me      <a href="http://twitter.com/bkjones">http://twitter.com/bkjones</a><br>