赞
踩
Python——输出大写英文字母
编写程序,顺序输出给定字符串中所出现过的大写英文字母,每个字母只输出一遍,若无大写字母则输出"Not Found"。
◆输入格式:输入一个以回车结束的字符串;
◆输出格式;按照 输入的顺序在一行中输出所出现过的大写英文字母,每个字母只输出一遍。若无大写英文字母则输出"Not Found"。
▪输入样例1:FONTNAME and FILENAME
▪输出样例1:FONTAMEIL
▪输入样例2:fontname and filename
▪输出样例2:Not Found
程序代码:
ls=input()
a=[]
b=0
for i in ls:
if 65<=ord(i)<=90:
b+=1
a.append(i)
if b!=0:
ls_set=set(a)
lst=list(ls_set)
lst.sort(key=a.index)
s="".join(map(str,lst))
print(s)
else:
print("Not Found")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。