def popular_genre(musics):
"""
Function that finds the most popular genre
:return: its name or "none" if all the songs are from different genres
"""
highest_frequency = 0
for song_no_1 in musics:
frequency = 0
for song_no_2 in musics:
if song_no_1.get_genre() == song_no_2.get_genre():
frequency += 1
if frequency > highest_frequency:
highest_frequency = frequency
tmp_genre = song_no_1.get_genre()
if highest_frequency == 1:
tmp_genre = "none"
return tmp_genre
So I want this function to show the most popular genre. musics
is a list of songs. I have 3 songs already and when I use this function like this popular_genre(musics)
nothing happens. Why?