0
点赞
收藏
分享

微信扫一扫

Python 字典的基本操作 题目练习

f12b11374cba 2022-04-21 阅读 44
python

查找字典条目

统计句子“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 条评论