s = 'xkhlboetagwpsotgx'题目要求输出最长字典序列,犯的错误很低级,,,
max=-1
result=''
for i in range(0,len(s)):
count=1
for j in range(i+1,len(s)):
if s[j:j+1]>=s[j-1:j]:
count+=1
else:
break
if count>max:
result=s[i:i+count]
max=count
print(result)
result=s[i:i+count]
i+count是对的,这才是位置,之前一直把count长度赋值给了字符串result,当然过不了了。。。