第3章-18 输出10个不重复的英文字母 (30分)python

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

输入格式:
在一行中输入字符串

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

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

poemp134

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

not found

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

This is a test example

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

Thisaexmpl

s1=input()
s=list()
count=0
for i in s1:
    if i.isalpha() and i.lower() not in s and i.upper() not in i.lower():
        s.append(i)                #注意一点语法:s=s.append()是初学者易犯的错误
        count=count+1
if count<10:
    print("not found")
else:
    for i in range(0,10):
        print(s[i],end="")
发布了59 篇原创文章 · 获赞 13 · 访问量 2577

猜你喜欢

转载自blog.csdn.net/weixin_45948920/article/details/104371828