题解 | #计算某字符出现次数#

计算某字符出现次数

https://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1

line1 = input().upper()
hash_table = dict()
for sub in line1:
    if not hash_table.get(sub):
        hash_table.setdefault(sub, 1)
    else:
        hash_table[sub] += 1
line2 = input().upper()
print(hash_table.get(line2, 0))

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务