Python Forum

Full Version: Write a code to output in alphabetical order
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi all i'm new here , i have a problem with my homework here if you can help me to solve it !

Assume 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 ties, print the first substring. For example, if s = 'abcbcd', then your program should print

Longest substring in alphabetical order is: abc
Hi, do you have an attempt/code that you can share with us so we can help you find mistakes in it?
If not, have you devised an algorithm or pseudo code for tackling the problem?