I am trying to write code that will do as the title says. If two substrings are the same size, simply print the first string
for example:
s = 'abcbcd'
would print out
'abc'
Here is what I have so far:
old_order = ''
re = ''
for r in range(len(s)):
order = ''
for letter in s[r:]:
try:
if letter <= s[s.index(letter)+1]:
order += letter
except:
order += letter
else:
order += letter
print(order)
if r is 0:
old_order = order
if len(order) > len(old_order):
re = order
else:
re = old_order
print(re)
what I am getting:
aabbcbbc