<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Looks like you're trying to turn it into a bunch of tokens. I'm assuming you have an arbitrarily long string.</div><div><br></div><div>You could loop through each character in the input, append it to the stack, determine whether the stack is &nbsp;a valid token, and output it (and reset the stack if so). In pseudocode:</div><div><br></div><div>def tokenizer(z):</div><div>&nbsp;&nbsp;def isValid(characterList):</div><div>&nbsp;&nbsp; &nbsp;return true if characterList is ['A'], ['T','/','G'], or ['C'] #this is pseudocode</div><div><br></div><div>&nbsp;&nbsp;stack = []</div><div>&nbsp;&nbsp;for character in z:</div><div>&nbsp;&nbsp; &nbsp;stack.append(character)</div><div>&nbsp;&nbsp; &nbsp;if (isValid(stack)):</div><div>&nbsp;&nbsp; &nbsp; &nbsp;yield ''.join(stack)</div><div><br></div><div>print(list(tokenizer("AT/CG")))</div><div><br></div><div>Disclaimer: This is absolutely not super-optimal and is untested (and my Python is rusty, I've been doing almost all Java and Objective-C lately) but it should get the job done if you just need something quick, I think.</div><br><div><div>On Aug 4, 2010, at 9:43 PM, Brian Rue wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Naive solution:<div><br></div><div>zlist = [z[0], z[1:4], z[4]]<br><br><div class="gmail_quote">On Wed, Aug 4, 2010 at 9:37 PM, Vikram K <span dir="ltr">&lt;<a href="mailto:kpguy1975@gmail.com">kpguy1975@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Suppose i have this string:<br>z = 'AT/CG'<br><br>How do i get this list:<br><br>zlist = ['A','T/C','G']<br>

<br>
<br>_______________________________________________<br>
Baypiggies mailing list<br>
<a href="mailto:Baypiggies@python.org">Baypiggies@python.org</a><br>
To change your subscription options or unsubscribe:<br>
<a href="http://mail.python.org/mailman/listinfo/baypiggies" target="_blank">http://mail.python.org/mailman/listinfo/baypiggies</a><br></blockquote></div><br></div>
_______________________________________________<br>Baypiggies mailing list<br><a href="mailto:Baypiggies@python.org">Baypiggies@python.org</a><br>To change your subscription options or unsubscribe:<br>http://mail.python.org/mailman/listinfo/baypiggies</blockquote></div><br></body></html>