编写程序,完成以下要求:
统计字符串中,各个字符的个数
比如:“hello world” 字符串统计的结果为: h:1 e:1 l:3 o:2 d:1 r:1 w:1
a = "hello world"
b = set(a)#除去重复元素
for i in b:
c = a.count(i)
print(i + ":",c,end = " ")
编写程序,完成以下要求:
统计字符串中,各个字符的个数
比如:“hello world” 字符串统计的结果为: h:1 e:1 l:3 o:2 d:1 r:1 w:1
a = "hello world"
b = set(a)#除去重复元素
for i in b:
c = a.count(i)
print(i + ":",c,end = " ")