题解 | 记票统计

记票统计

https://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894

import sys
index = 0
he = set()
sunhe = []
d = {"Invalid":0}
for line in sys.stdin:
    a = line.split("\n")[0]
    if index == 1:
        aa = a.split(" ")
        [sunhe.append(_) for _ in aa]
        he = set(sunhe)
    if index == 3:
        aa = a.split(" ")
        for _ in aa:
            if _ in he:
                if _ not in d:
                    d[_]=0
                d[_]+=1
            else:
                d["Invalid"]+=1
    index += 1
for k in sunhe:
    print("%s : %s" % (k,d.get(k,0)))
print("%s : %s" % ("Invalid",d.get("Invalid",0)))

全部评论

相关推荐

Rena1ssance_:对的,要是面评没太烂,勤更新简历等捞就行了,腾讯可以无限复活
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务