string

in ita •  4 months ago 

res = ""

for i in range(len(s)):
n = i
while n <len(s)-1 and s[n] <= s[n+1]:
n += 1
if n+1-i > len(res):
res = s[i:n+1]

print('Longest substring in alphabetical order is: '+res)

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!