Created
June 25, 2015 16:53
-
-
Save obasekiosa/0a868c7e1e15ab334855 to your computer and use it in GitHub Desktop.
hello...can someone please tell me how to fix the bug in this code, I tried all i could but...am here..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kip = [] | |
s = raw_input('give me a string: ') | |
v = s[len(s) - 1] | |
for a in range(len(s)): | |
store = s[a] | |
for i in range(len(s)): | |
z = v == s[len(s) - 1] | |
if z == True: | |
c = (i + 1 >= len(s)) | |
if c == False: | |
while s[i] < s[i + 1]: | |
if store == '': | |
store = s[i] | |
store += s[i + 1] | |
s = s.translate(None, s[i]) | |
kip.append(store) | |
store = '' | |
else: | |
break | |
kip.append(store) | |
store = '' | |
Lngst = len(max(kip,key=len)) # key=len takes length in consideration | |
for i in range(0,len(kip)): | |
d = len(kip[i]) | |
if d == Lngst: | |
print 'Longest substring in alphabetical order is:' + str(kip[i]) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment