英文辅音字母是除A
、E
、I
、O
、U
以外的字母。本题要求编写程序,统计给定字符串中大写辅音字母的个数。
输入格式:
输入在一行中给出一个不超过80个字符、并以回车结束的字符串。
输出格式:
输出在一行中给出字符串中大写辅音字母的个数。
输入样例:
HELLO World!
输出样例:
4
方法一:
l1=list(input())
l2=[i for i in l1 if(65<=ord(i)<=90and (i not in ['A','E','I','O','U']))]
print(len(l2))
方法二:
l1=list(input())
l2=[i for i in l1 if(65<=ord(i)<=90and i!='A' and i!='E' and i!='I' and i!='O' and i!='U')]
print(len(l2))
方法三:
s1=input()
count=0
for i in range(len(s1)):
if (65<=ord(s1[i])<=90and (s1[i] not in ['A','E','I','O','U'])):
count+=1
print(count)