找出给定字符串中大写字符(即'A'-'Z')的个数。
数据范围:字符串长度:
字符串中可能包含空格或其他字符
进阶:时间复杂度:,空间复杂度:
对于每组样例,输入一行,代表待统计的字符串
输出一个整数,代表字符串中大写字母的个数
A 1 0 1 1150175017(&^%&$vabovbaoadd 123#$%#%#O
2
s = input().split() str_=''.join(s) count = 0 for i in str_: if i.isupper() : count += 1 print(count)
s = input() n = 0 for i in s: if i.isupper(): n += 1 print(n)
s=input() count=0 for i in s: if i.isupper(): count+=1 print(count)
ip = input() count = 0 for char in ip: if ord("A") <= ord(char) <= ord("Z"):count += 1 print(count)
n = input() l = [] for i in n: if i.isalpha(): l.append(i) l1 =[] for j in l: if j.upper() ==j: l1.append(j) print(len(l1))