Quick question concerning a function including a list



My original function was

def more_than_n(lst, item, n):
if item > lst.count(n):
return True
else: return False

it returned correctly until it hit an equal int.
at that time, it returned True instead of False.


Hi @jacobjenson424642936,

The instructions include this …

The function should return True if item appears in the list more than n times.

However, here you are counting the occurrences of n in lst and comparing the result to item

  if item > lst.count(n):

Instead, you need to count the occurrences of item in lst and compare the result to n.