fork download
  1. def get_all_substrings(string):
  2. for index in range(len(string)):
  3. yield string[index:]
  4.  
  5. def get_bigest_substring(string):
  6. for index, characters in enumerate(zip(string, string[1:])):
  7. a, b = characters
  8. if b < a:
  9. return string[:index+1]
  10. return string
  11.  
  12. substrings = (get_bigest_substring(string)
  13. for string in get_all_substrings('azcbobobegghakl'))
  14.  
  15. bigest_substring = max(substrings, key=len)
  16.  
  17. print(bigest_substring)
  18.  
  19.  
Success #stdin #stdout 0.04s 9260KB
stdin
Standard input is empty
stdout
beggh