Python练习——输出10个不重复的英文字母

Python练习——输出10个不重复的英文字母

随机输入一个字符串,把最左边的10个不重复的英文字母(不区分大小写)挑选出来。 如没有10个英文字母,显示信息“not found”

输入格式:

在一行中输入字符串

输出格式:

在一行中输出最左边的10个不重复的英文字母或显示信息“not found"

输入样例1:

在这里给出一组输入。例如:
poemp134

输出样例1:

在这里给出相应的输出。例如:
not found

输入样例2

在这里给出一组输入。例如:
This is a test example

输出样例2:

在这里给出相应的输出。例如:
Thisaexmpl

s = input()
b = []
for i in s:
    if i.isalpha() and (i.upper() not in b) and (i.lower() not in b):
        b.append(i)
str = "".join(b)
if len(str)>=10:
    print(str[:10])
else:
    print("not found")

你可能感兴趣的:(Python练习)