200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > python统计数字 大写字母 小写字母 空格个数

python统计数字 大写字母 小写字母 空格个数

时间:2023-12-16 13:28:12

相关推荐

python统计数字 大写字母 小写字母 空格个数

s=input()

num,Bchar,Schar,space,other = 0,0,0,0,0

for i in s:

if i.isdigit():

num+=1

elif i.isupper():

Bchar+=1

elif i.islower():

Schar+=1

elif i.isspace():

space+=1

else:

other+=1

print(f’大写字母个数{Bchar}、小写字母个数: {Schar}、数字个数: {num}、空格个数: {space}、其他字符个数: {other}')

s=input()num,Bchar,Schar,space,other = 0,0,0,0,0for i in s:if i.isdigit():num+=1elif i.isupper():Bchar+=1elif i.islower():Schar+=1elif i.isspace():space+=1else:other+=1print(f'大写字母个数{Bchar}、小写字母个数: {Schar}、数字个数: {num}、空格个数: {space}、其他字符个数: {other}')

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。