fork download
  1. c = ''
  2. a = []
  3. s='vsyakayazalupa'
  4. for x in range(len(s)):
  5. try:
  6. if int(ord(s[x])) <= int(ord(s[x+1])):
  7. c += s[x]
  8. # print (c)
  9. else:
  10. c += s[x]
  11. a.append(c)
  12. c = ''
  13. except IndexError:
  14. c+=s[x]
  15. a.append(c)
  16. break
  17. res=[]
  18. maxlength = max(len(q) for q in a)
  19. for i in a:
  20. if len(i) == maxlength:
  21. res.append(i)
  22. print('Longest substring in alphabetical order is: ', res[0])
Success #stdin #stdout 0.01s 28384KB
stdin
Standard input is empty
stdout
Longest substring in alphabetical order is:  alu