1、不区分大小写
2、返回连续最长串的长度
3、拷贝给新串
例如:输入123abcdefg2141as324
返回最长字串为abcdefg
字串长度为7
#! /usr/bin/python
def test_1(a):
a=a.lower()
result=[]
all_words="abcdefghijklmnopqrstuvwxyz"
re=[]
for i in range(1,len(a)+1):
str_list=[]
result={}
for j in range(0,i):
if a[j:len(a)-i+j+1] in all_words:
str_list.append(a[j:len(a)-i+j+1])
result[len(a)-i+1]=list(set(str_list))
else:
pass
re.append(result)
for i in re:
if i:
for k,v in i.items():
return k,v
if __name__=="__main__":
a='aabAhijkvWxysasz'
print(test_1(a))
网友评论