Guest User

Untitled

a guest
Oct 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. s = "abcbcd"
  2. alph = "abcdefghijklmnopqrstuvwxyz"
  3. temp = 0
  4. list = ""
  5. fin = []
  6. for i in range(len(s)):
  7.  
  8. if s[i] in alph:
  9. fin.append(list)
  10. list = list + s[i]
  11. prev = alph.index(s[i])
  12. if prev >= temp:
  13. temp = prev
  14. else:
  15. temp = 0
  16. list = ""
  17. prev = alph.index(s[i])
  18. if prev >= temp:
  19. temp = prev
  20. list = list + s[i]
  21. fin.append(list)
  22. #print fin
  23. max = 0
  24. get = ""
  25. for each in fin:
  26. if max<len(each):
  27. max = len(each)
  28. get = each
  29.  
  30. print "Longest string in alphabetical order is: "+get
Add Comment
Please, Sign In to add comment