第3章-9.统计大写辅音字母 (15分)

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

输入格式:

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

输出格式:

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

输入样例:

HELLO World!
 

输出样例:

4
 1 # 统计大写辅音字母
 2 # Author: cnRick
 3 # Time  : 2020-3-25
 4 judge_data = ('A','E','I','O','U')
 5 aStr = input()
 6 result = 0
 7 for i in range(len(aStr)):
 8     if(aStr[i] not in judge_data and 'A' <= aStr[i] <= 'Z'):
 9         result = result + 1
10 print(result)
 
原文地址:https://www.cnblogs.com/dreamcoding/p/12567537.html