I am a beginner and am trying to write a piece of code that tells you how long the longest substring is that is written in alphabetic order.
So far I have:
s = 'azcbobobegghakl'
n=len(s)
i=0
longest=1
while i<n+1:
print(s[i])
if s[i] < s[i+1]:
longest+=1
i+=1
else:
i+=1
print(longest)
However I keep getting an error:
IndexError: string index out of range
Could somebody please tell me where I am going wrong and how to fix it