wrote
a.partition('<')
('', '<', 'NAME')
Ooh! A new string method for me. I've never notioced partition before.
Thanks for posting.
Alan G.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.pyth
You can also try this
>>> a = '>> a
'>> a.partition('<')
('', '<', 'NAME')
>>> splitstring = a.partition('<')
>>> splitstring
('', '<', 'NAME')
>>> splitstring[0]
''
>>> splitstring[1]
'<'
>>> splitstring[2]
'NAME'
I guess you can use this tuple.
Hope this helps.
Thanks and Regards,
Sumod
On F
"Spyros Charonis" wrote
A quick string processing query. If I have an entry in a list such
as
['>NAME\n'],
is there a way to split it into two separate lines:
NAME
Yes if you know where the linebreak will be.
s = ">NAME\n"
twolines = [s[0],s[1:]] # list of two strings
for line in tw