you can use an re split...
import re
a=raw_input("Enter the number of your class in the school:")
regex = re.compile("[ ,]") #sets the delimeters to a single space or comma
m = regex.split(a)
if you want to use any white space character than you can use "[\s,]"
2010/9/23 Ahmed AL-Masri
> Hi,
Brian Jones wrote:
> No need for the 're' module. Even in the case where both can be used
> together, you can still just use string methods:
>
s
> '12, 13 14'
s.replace(',', '').split(' ')
> ['12', '13', '14']
I think to replace "," with " " and then split() without explicit separator
> > any one have an idea about how we can input many number in the one time and
> > change it to list.
> > for example:
> >
> > a=input("Enter the number of your class in the school:") # the number
> > can be enter as: 12,13,14 or 12 13 14 with a space in between.
> >
> > now how I can put th
On Sat, Sep 25, 2010 at 9:40 AM, Evert Rol wrote:
> > any one have an idea about how we can input many number in the one time
> and change it to list.
> > for example:
> >
> > a=input("Enter the number of your class in the school:") # the number
> can be enter as: 12,13,14 or 12 13 14 with a
> any one have an idea about how we can input many number in the one time and
> change it to list.
> for example:
>
> a=input("Enter the number of your class in the school:") # the number can
> be enter as: 12,13,14 or 12 13 14 with a space in between.
>
> now how I can put these numbers
Hi,
any one have an idea about how we can input many number in the one time and
change it to list.
for example:
a=input("Enter the number of your class in the school:") # the number can
be enter as: 12,13,14 or 12 13 14 with a space in between.
now how I can put these numbers into list like