查找字典条目
统计句子“Life is short,we need Python.”中各字符出现的次数。
s='Life is short,we need Python.'
s=s.lower()
print(s)
dic={}
for a in s:
dic[a] = dic.get(a,0) + 1
for k in dic:
print(k,dic[k])
Python 字典的基本操作 题目练习
阅读 45
2022-04-21
统计句子“Life is short,we need Python.”中各字符出现的次数。
s='Life is short,we need Python.'
s=s.lower()
print(s)
dic={}
for a in s:
dic[a] = dic.get(a,0) + 1
for k in dic:
print(k,dic[k])
相关推荐
精彩评论(0)