Python练习——统计大写辅音字母

Python练习——统计大写辅音字母

英文辅音字母是除A、E、I、O、U以外的字母。本题要求编写程序,统计给定字符串中大写辅音字母的个数。

输入格式:

输入在一行中给出一个不超过80个字符、并以回车结束的字符串。

输出格式:

输出在一行中给出字符串中大写辅音字母的个数。

输入样例:

HELLO World!

输出样例:

4

s = input()
str = "AEIOU"
cnt = 0
for i in s:
    if i == i.upper() and i.upper()>='A'and i.upper()<='Z':
        if i not in str:
            cnt = cnt+1
print(cnt)
发布了169 篇原创文章 · 获赞 5 · 访问量 8718

猜你喜欢

转载自blog.csdn.net/linjiayina/article/details/104390572
今日推荐