Delete occurrences of an element if it occurs more than n times
当序列中某元素出现次数的超出n次,删除
def delete_nth(l, max_e):
r = []
for i in l:
if r.count(i) < max_e:
r.append(i)
return r
Delete occurrences of an element if it occurs more than n times
当序列中某元素出现次数的超出n次,删除
def delete_nth(l, max_e):
r = []
for i in l:
if r.count(i) < max_e:
r.append(i)
return r