How am I supposed to define ‘n’ in the below scenario? What is ‘n’? Is it the number of items in the list or is it a specific number?
Create a function named
more_than_n
that has three parameters namedlst
,item
, andn
.The function should returnTrue
ifitem
appears in the list more thann
times. The function should returnFalse
otherwise.
Here is what I have so far:
#Write your function here
def more_than_n(lst, item, n):
length_list = len(lst)
if item > length_list:
return True
else:
False
#Uncomment the line below when your function is done
print(more_than_n([2, 4, 6, 2, 3, 2, 1, 2], 2, 3))