[Tutor] how to split/partition a string on keywords?
ALAN GAULD
alan.gauld at btinternet.com
Fri Aug 24 00:55:56 CEST 2012
>>>> h,s,t = st.partition(' and')
>
>The keyword needs a space at both ends:
>
> >>> st = 'an androphobic andromedan android'
> >>> results
> ['an', ' and', 'rophobic', ' and', 'romedan', ' and', 'roid', '']
>
>Good catch, although to be honest I intended it to have a space...
>But I didn't check the output closely enough! :-(
>
>
>Alan g.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120823/32922089/attachment.html>
More information about the Tutor
mailing list