I'm solving some katas in CodeWars and in the current kata I'm trying to get how many times an element has occurred in a list that I set as a parameter, then and use it as the range of a for loop.
However, when I call the function it returns:
File "<pyshell#8>", line 3, in delete_nth
if order.count(item) > max_e:
AttributeError: 'NoneType' object has no attribute 'count'
here is my code
def delete_nth(order,max_e):
for item in order:
if order.count(item) > max_e:
for i in range(order.count(item) - max_e):
order = order.remove(item)
return order
l = [20,37,20,21]
delete_nth(l,1) #except [20,37,21]