"Vikram K" <kpguy1...@gmail.com> wrote

Suppose i have this string:
z = 'AT/CG'

How do i get this list:

zlist = ['A','T/C','G']

There are lots of ways and it really needs a tighter specification of yhow you split.

What would "AT/C/DGH" give for example?

But in general there are several approaches, I suspect regex is the best solution here but for simple solutions splitting by the / then splitting the sublists then joining the last to the first element of each sublist using / might
work too. But regex is probably faster, although more complex.

And you could use a parser if the rules are very complex.

HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/



_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to