随机输入一个字符串,把最左边的10个不重复的英文字母(不区分大小写)挑选出来。 如没有10个英文字母,显示信息“not found”
输入格式:
在一行中输入字符串
输出格式:
在一行中输出最左边的10个不重复的英文字母或显示信息“not found"
输入样例1:
在这里给出一组输入。例如:
poemp134567
输出样例1:
在这里给出相应的输出。例如:
not found
输入样例2
在这里给出一组输入。例如:
This 156is a test example
输出样例2:
在这里给出相应的输出。例如:
Thisaexmpl
代码如下:
s = input()
temp = []
temp.append(s[0])
for i in range(1,len(s)):
if ((s[i] >= 'a' and s[i] <= 'z') or (s[i] >= 'A' and s[i] <= 'Z')) and (s[i] not in temp[:len(temp)] and chr(ord(s[i])-32) not in temp[:len(temp)] and chr(ord(s[i])+32) not in temp[:len(temp)]): #temp[]里没有与之相同的大小写字母,则存入temp[].
temp.append(s[i])
if len(temp) < 10:
print("not found")
else:
print(''.join(temp[:10]))
提交结果: