wuyijiong
2024-11-16 17:16:56
发布于:浙江
2阅读
0回复
0点赞
读取输入
N = int(input())
names = []
for _ in range(N):
name = input()
names.append(name)
统计名字出现次数
name_count = {}
for name in names:
if name in name_count:
name_count[name] += 1
else:
name_count[name] = 1
找到出现次数最多的名字
max_count = 0
most_frequent_name = ""
for name, count in name_count.items():
if count > max_count:
max_count = count
most_frequent_name = name
输出结果
print(most_frequent_name, max_count)
这里空空如也
有帮助,赞一个