On 5 August 2010 06:38, 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']
If you know the format of the string is always the same you can do something like this. This fails when you have strings that do not have the '/' in the middle and has 2 characters on either side. def parseString(s): n = s.find('/') l = [] if n: l = [s[0],s[n-1:n+2], s[-1]] return l >>> parseString(s) ['A', 'T/C', 'G'] Greets Sander _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor