Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s = "abcbcd"
- alph = "abcdefghijklmnopqrstuvwxyz"
- temp = 0
- list = ""
- fin = []
- for i in range(len(s)):
- if s[i] in alph:
- fin.append(list)
- list = list + s[i]
- prev = alph.index(s[i])
- if prev >= temp:
- temp = prev
- else:
- temp = 0
- list = ""
- prev = alph.index(s[i])
- if prev >= temp:
- temp = prev
- list = list + s[i]
- fin.append(list)
- #print fin
- max = 0
- get = ""
- for each in fin:
- if max<len(each):
- max = len(each)
- get = each
- print "Longest string in alphabetical order is: "+get
Add Comment
Please, Sign In to add comment