# -*- coding: utf-8 -*-
"""
Created on Mon Feb  1 06:49:24 2021

@author: dell

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
Note: This problem may be challenging. We encourage you to work smart. If you've spent more than a few hours on this problem, we suggest that you move on to a different part of the course. If you have time, come back to this problem after you've had a break and cleared your head.
"""

s='abcdeoaisfausfaufnstuvwuayvfuybdsfxyz'

longest = s[0]
current = s[0]
for index in range(len(s)-1):
    if s[index+1] >= s[index]:
        current += s[index+1]
        if len(longest) < len(current):
            longest = current
    else:
        current = s[index+1]
    index += 1
print("Longest substring in alphabetical order is: "+longest)
9318562906a65fa63ce64100cd77557736f38fc2
<mask token>

<mask token>
for index in range(len(s) - 1):
    if s[index + 1] >= s[index]:
        current += s[index + 1]
        if len(longest) < len(current):
            longest = current
    else:
        current = s[index + 1]
    index += 1
print('Longest substring in alphabetical order is: ' + longest)

<mask token>
s = 'abcdeoaisfausfaufnstuvwuayvfuybdsfxyz'
longest = s[0]
current = s[0]
for index in range(len(s) - 1):
    if s[index + 1] >= s[index]:
        current += s[index + 1]
        if len(longest) < len(current):
            longest = current
    else:
        current = s[index + 1]
    index += 1
print('Longest substring in alphabetical order is: ' + longest)

# -*- coding: utf-8 -*-
"""
Created on Mon Feb  1 06:49:24 2021

@author: dell

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
Note: This problem may be challenging. We encourage you to work smart. If you've spent more than a few hours on this problem, we suggest that you move on to a different part of the course. If you have time, come back to this problem after you've had a break and cleared your head.
"""

s='abcdeoaisfausfaufnstuvwuayvfuybdsfxyz'

longest = s[0]
current = s[0]
for index in range(len(s)-1):
    if s[index+1] >= s[index]:
        current += s[index+1]
        if len(longest) < len(current):
            longest = current
    else:
        current = s[index+1]
    index += 1
print("Longest substring in alphabetical order is: "+longest)