On 03/02/10 13:19, NISA BALAKRISHNAN wrote:
hi

I am very new to python.
I have a string for example : 123B     new Project
i want to separate 123B as a single string and new project as another string .
how can i do that.
i tried using partition but couldnt do it

pls help.
thanks in advance!


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Assuming the whitespace isn't relevant, and is just a delimiter:

>>> s = '123B     new Project'
>>> s.split(None, 1)
['123B', 'new Project']

The first argument to split() is the delimiter (or if None, it defaults to whitespace), and the second argument is 'maxsplit' - the amount of splits to make. It's explained well in the documentation[1].

Cheers,

Daz

[1]http://docs.python.org/library/stdtypes.html#str.split
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to