Try this: test = u"Hello World"
n = range(len(test)) for i in n: cur = test[i] try: next = test[i+1] except: next = "" print cur, next just On 10/10/07, Robert Dailey <[EMAIL PROTECTED]> wrote: > > Hi, > > I'm currently writing my own CSV parser since the built in one doesn't > support Unicode. I'm wondering if there's a way to iterate over the > characters in a unicode string and have access to both the 'current' and the > 'next' characters each iteration. For example: > > test = u"Hello World" > > for cur,next in test: > print cur,next > > Ideally, this would output: > > 'H', 'e' > 'e', 'l' > 'l', 'l' > 'l', 'o' > etc... > > Of course, the for loop above isn't valid at all. I am just giving an > example of what I'm trying to accomplish. Anyone know how I can achieve the > goal in the example above? Thanks. > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Rafael Sachetto Oliveira Sir - Simple Image Resizer http://rsachetto.googlepages.com
-- http://mail.python.org/mailman/listinfo/python-list