admin管理员组文章数量:1025800
def favoriteSinger(n, songs):
singer_counts = {}
max_count = 0
for singer in songs:
singer_counts[singer] = singer_counts.get(singer, 0) + 1
max_count = max(max_count, singer_counts[singer])
favorite_singers = 0
for singer, count in singer_counts.items():
if count == max_count:
favorite_singers += 1
return favorite_singers
n = int(input())
songs = list(map(int, input().split()))
print(favoriteSinger(n,song))
here my code not working in idle please fix the error
def favoriteSinger(n, songs):
singer_counts = {}
max_count = 0
for singer in songs:
singer_counts[singer] = singer_counts.get(singer, 0) + 1
max_count = max(max_count, singer_counts[singer])
favorite_singers = 0
for singer, count in singer_counts.items():
if count == max_count:
favorite_singers += 1
return favorite_singers
n = int(input())
songs = list(map(int, input().split()))
print(favoriteSinger(n,song))
here my code not working in idle please fix the error
本文标签: pythonHow to solve this fav singer selection codeStack Overflow
版权声明:本文标题:python - How to solve this fav singer selection code - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745639033a2160629.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论