[Tutor] string to list

James Mills prologic at shortcircuit.net.au
Thu Aug 5 09:25:55 CEST 2010


On Thu, Aug 5, 2010 at 2:38 PM, Vikram K <kpguy1975 at gmail.com> wrote:
> Suppose i have this string:
> z = 'AT/CG'
>
> How do i get this list:
>
> zlist = ['A','T/C','G']

>>> import re
>>> z = 'AT/CG'
>>> [x for x in re.split("([A-Z]\/[A-Z])|([A-Z])", z) if x]
['A', 'T/C', 'G']
>>>

cheers
James

-- 
-- James Mills
--
-- "Problems are solved by method"


More information about the Tutor mailing list