python - How to solve this fav singer selection code - Stack Overflow

def favoriteSinger(n, songs):singer_counts = {}max_count = 0for singer in songs:singer_counts[singer] =

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745639035a4637574.html

相关推荐

  • python - How to solve this fav singer selection code - Stack Overflow

    def favoriteSinger(n, songs):singer_counts = {}max_count = 0for singer in songs:singer_counts[singer] =

    9小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信