题解 | #记票统计#
记票统计
https://www.nowcoder.com/practice/3350d379a5d44054b219de7af6708894
n = input().strip()
candidate = input().strip().split()
m = input().strip()
ticket = input().strip().split()
summary = {}
for t in ticket:
if t not in candidate:
summary["Invalid"] = summary.get("Invalid", 0) + 1
else:
summary[t] = summary.get(t, 0) + 1
for c in candidate:
print(f'{c} : {summary.get(c, 0)}')
print("Invalid", ":", summary.get('Invalid', 0))
阿里云工作强度 588人发布