+ 1

How to solve this question? (Python)

I'm stuck with a question related to Python. The question is... ------------------------------------------------------------------------------------------------------------- s ='fgsgebgwtegvberwhttrjyjjklsme' # s is a string of lower case characters. "Write a program that prints the longest substring of s in which the letters occur in alphabetical order. For example, if s = 'azcbobobegghakl', then your program should print, >>>Longest substring in alphabetical order is: beggh In the case of the case of ties, print the first substring. For example, if s = 'abcbcd', then your program should print, >>> Longest substring in alphabetical order is: abc ------------------------------------------------------------------------------------------------------------- The most difficult thing from this question was that I have to compare length .. :( Above was the question. And actually I want some instruction or conception that I need to know to solve this question! Thank you for reading :):):) Have a nice day:) !!!

9th Jun 2020, 5:24 AM
beanibeanibean
beanibeanibean - avatar
2 ответов
+ 4
iterate string. if next letter >= actual letter len +=1 else check if it was longest up to now len =1
9th Jun 2020, 6:06 AM
Oma Falk
Oma Falk - avatar
+ 2
The submissions for this assignment may be inspiring, though a little bit different. https://www.sololearn.com/learn/4743/?ref=app
9th Jun 2020, 5:31 AM
Ipang