Very nice solution :)<br><br><div><span class="gmail_quote">On 10/10/07, <b class="gmail_sendername">Paul Hankin</b> <<a href="mailto:paul.hankin@gmail.com">paul.hankin@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Oct 10, 9:12 pm, Tim Chase <<a href="mailto:python.l...@tim.thechases.com">python.l...@tim.thechases.com</a>> wrote:<br>> > test = u"Hello World"<br>><br>> > for cur,next in test:<br>> >     print cur,next
<br>><br>> > Ideally, this would output:<br>><br>> > 'H', 'e'<br>> > 'e', 'l'<br>> > 'l', 'l'<br>> > 'l', 'o'<br>> > etc...
<br>><br>> > Of course, the for loop above isn't valid at all. I am just giving an<br>> > example of what I'm trying to accomplish. Anyone know how I can achieve the<br>> > goal in the example above? Thanks.
<br>><br>> A "works-for-me":<br>><br>>  >>> pairs = (test[i:i+2] for i in xrange(len(test)-1))<br>>  >>> for a,b in pairs:<br>> ...     print a,b<br><br>for a, b in zip(test, test[1:]):
<br>  print a, b<br><br>--<br>Paul Hankin<br><br>--<br><a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a><br></blockquote></div><br><br clear="all"><br>-- 
<br>Rafael Sachetto Oliveira<br><br>Sir - Simple Image Resizer<br><a href="http://rsachetto.googlepages.com">http://rsachetto.googlepages.com</a>