题解 | 记票统计

记票统计

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

while True:
    try:
        n = map(int, input())
        name_list = input().split()
        m = map(int, input())
        vote_name = input().split()
        # print(vote_name)
        vote_dict = {}
        for i in name_list:
            vote_dict[i] = vote_name.count(i)
        # print(vote_dict)
        Invalid_count = 0
        for j in vote_name:
            if j not in name_list:
                Invalid_count += 1
        vote_dict['Invalid'] = Invalid_count
        # print(vote_dict)
        for key, value in vote_dict.items():
            print(key, ':', value)
    except Exception as e:
        break

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务