第3章-22 输出大写英文字母 (15分)【python】

本题要求编写程序,顺序输出给定字符串中所出现过的大写英文字母,每个字母只输出一遍;若无大写英文字母则输出“Not Found”。

输入格式:
输入为一个以回车结束的字符串(少于80个字符)。

输出格式:
按照输入的顺序在一行中输出所出现过的大写英文字母,每个字母只输出一遍。若无大写英文字母则输出“Not Found”。

输入样例1:
FONTNAME and FILENAME

      
    
输出样例1:
FONTAMEIL

      
    
输入样例2:
fontname and filrname

      
    
输出样例2:
Not Found
str = input()
str1 = ''
flag = 1
for i in str:
    if(i>='A' and i<='Z'):
        if(str1.find(i) == -1):
            flag = 0
            str1 = str1 + i
if(flag == 1):
    print("Not Found")
else:
    print(str1)
exit(0)
发布了363 篇原创文章 · 获赞 95 · 访问量 18万+

猜你喜欢

转载自blog.csdn.net/qq_43788669/article/details/105423742