def fucking_filter(arr, max_count, key=lambda n: n):
filtered = []
count = {}
for n in arr:
k = key(n)
count[k] = count.get(k, 0) + 1
if count[k] <= max_count:
filtered.append(n)
return filtered
for n in fucking_filter(genres, N):
print(n)
from random import sample
arr = [ 'AAA', 'BBB', 'CCC', 'DDD', 'EEE', 'FFF', 'GGG', 'HHH' ]
string = ''.join(sample(arr, k=len(arr)))
from random import choice
chars = '0123456789abcdefghijklmnopqrstuvwxyz'
section_size = 4
sections_num = 5
string = '-'.join(''.join(choice(chars) for j in range(section_size)) for i in range(sections_num))
import re
def has_consecutive_characters(s, count):
return bool(re.search(rf'([\dA-Z])\1{{{count - 1}}}', s, re.IGNORECASE))
arr = [
'PAaAssword',
'Paaaassword',
'P111ssword',
'Password',
]
print([ has_consecutive_characters(n, 3) for n in arr ])