def g(x):
a=0
b=0
c=0
d=0
for i in x:
if i.isupper():
a+=1
elif i.islower():
b+=1
elif i.isdigit():
c+=1
else:
d+=1
return(a,b,c,d)
print(g(input('input a character string:')))
编写函数,接收一个字符串,分别统计大写字母、小写字母、数字、其他字符的个数,并以元组形式返回结果
最新推荐文章于 2022-12-29 20:01:50 发布