题解 | #记票统计# list.count(i)
记票统计
https://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894
''' n1=int(input()) candidate=input().split() candidate.append('Invalid') n2=int(input()) vote=input().split() #print(candidate,vote) ticket_cnt={} n_valid=0 for i in candidate: n=0 for j in vote: # 可以直接用list.count(i)计数 if j==i: n += 1 #print(n) ticket_cnt[i]=n n_valid += n ticket_cnt['Invalid']=n2-n_valid #print(ticket_cnt,n_valid) for i in ticket_cnt: print(i,':',ticket_cnt[i]) ''' n1=int(input()) candidate=input().split() n2=int(input()) vote=input().split() n_valid=0 for i in candidate: print(i,':',vote.count(i)) n_valid += vote.count(i) print('Invalid :',n2-n_valid)