题解 | #记票统计#
记票统计
http://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894
字典生成式多用用
num1 = input() list1 = input().split(' ') num2 = input() list2 = input().split(' ') data = {key:0 for key in list1} data['Invalid'] = 0 for i in list2: if i in data.keys(): data[i] += 1 else: data['Invalid'] += 1 for key,values in data.items(): print('{0} : {1}'.format(key, values))