I am trying to figure out how to compare a character in a string to the next character in the string. For example, if I have a string:
s = \'vzcbotdebobeggg
This is less obvious, but seems to work:
seq = "vzcbotdebobeggglakyl" import itertools result = max( ( list(next(sub)) + [b for a, b in sub] for ascending, sub in itertools.groupby(zip(seq,seq[1:]), lambda x: x[0] <= x[1]) if ascending ), key=len ) print ''.join(result)