标签:NPU pre end div string int print span app
输入一个字符串,返回字符串中第一次出现的长度最长的字符串。
string=input("please input:") str_list = list(string) len_list = len(str_list) middel = [] result = [] index = 0 for i in str_list: if index <= len_list-2: middel.append(i) for ind in range(index+1,len_list): if str_list[ind] in middel: break middel.append(str_list[ind]) ls = ‘‘.join(middel) result.append(ls) middel=[] index = index+1 middel=[] for ele in result: middel.append(len(ele)) index=middel.index(max(middel)) print(result[index])
标签:NPU pre end div string int print span app
原文地址:https://www.cnblogs.com/yundanfengqingxq/p/10165985.html