题解 | #统计大写字母个数#

统计大写字母个数

https://www.nowcoder.com/practice/434414efe5ea48e5b06ebf2b35434a9c?tpId=37&tqId=21307&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D2%26tpId%3D37%26type%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=

import sys




'''
接收输入的字符串
'''
while True:
    try:
	  #将字符串中的s的元素放到列表中,准备进行遍历
        s = list(input())
        def CountUpper(s):
            '''
            统计大写字母的个数
            '''
            L=[]
			#定义L用于存放大写字母
            for x in s:
                if x.isupper():
                    L.append(x)
					
					
			#计算大写字母的长度,并返回
            count=len(L)
            print(count)
            return count

        CountUpper(s)
    except:
        break

全部评论

相关推荐

昨天 20:51
门头沟学院 golang
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务