随机输入一个字符串,把最左边的10个不重复的英文字母(不区分大小写)挑选出来。 如没有10个英文字母,显示信息“not found”
输入格式:
在一行中输入字符串
输出格式:
在一行中输出最左边的10个不重复的英文字母或显示信息“not found"
输入样例1:
在这里给出一组输入。例如:
poemp134
输出样例1:
在这里给出相应的输出。例如:
not found
输入样例2
在这里给出一组输入。例如:
This is a test example
输出样例2:
在这里给出相应的输出。例如:
Thisaexmpl
——————
之前的代码丢了,下面是问题记录
————————
①直接用len()函数即可
②不能在for前面就a.lower() 题目里的样例没有改变大小写
③多个条件可以用if和and结合起来 不必要一个i一个j
答案:
a = input()
n = []
for i in a:
if i.isalpha() and (i.upper() not in n) and (i.lower() not in n):
n.append(i)
str = “”.join(n)
if len(str)>=10:
print(str[:10])
else:
print(“not found”)