Python 3, Advanced Python Code Challenges: Lists 3. More Frequent Item

Can someone assist, please? I don’t understand why it doesn’t return the value of item1.


#Write your function here
def more_frequent_item(lst, item1, item2):
if lst.count(item1) >= lst.count(item2):
return item1
return item2
#Uncomment the line below when your function is done
print(more_frequent_item([2, 3, 3, 2, 3, 2, 3, 2, 3], 2, 3))

1 Like

Hello @azurerae :grinning:

Perhaps I misunderstand your problem.

As far as I can tell the code works perfectly, there are four 2s and five 3s.
And the code returns 3 as the more frequent item.

1 Like

jeez, i’m such a dork! thanks and sorry.

1 Like

All good, everyone makes mistakes, especially if you have been working on something for awhile. :slight_smile: