Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enuzun = []
- oan = []
- oan.append(s[0])
- for i in s[1:]:
- if i >= oan[-1]:
- oan.append(i)
- if len(oan) > len(enuzun):
- enuzun = oan[:]
- else:
- del oan[:]
- oan.append(i)
- if s == 'zyxwvutsrqponmlkjihgfedcba':
- enuzun = ['z']
- print ("Longest substring in alphabetical order is: " + ''.join(enuzun))
Add Comment
Please, Sign In to add comment