fork download
  1. s='abc'
  2. b=[]
  3. count=1
  4. j=0
  5. for i in range(0,len(s)-2):
  6. if(s[i]<=s[i+1]):
  7. count=count+1
  8. if(i==(len(s)-2)):
  9. x=s[j:(j+count)]
  10. b.append(x)
  11. break
  12.  
  13. if(s[i]>s[i+1]):
  14. x=s[j:(j+count)]
  15. b.append(x)
  16. continue
  17.  
  18.  
  19.  
  20. max_length=len(b[0])
  21. elem=b[0]
  22. for i in range(0,len(b)-1):
  23. if(len(b[i+1])>max_length):
  24. max_length=len(b[i+1])
  25. elem=b[i+1]
  26.  
  27.  
  28. print"Longest substring in alphabetical order is:",elem
  29.  
  30.  
  31.  
Runtime error #stdin #stdout #stderr 0.01s 9008KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 20, in <module>
IndexError: list index out of range