Answer the question
In order to leave comments, you need to log in
How to write a filter for output to the console based on the passed argument?
There is a list with recurring genres. I need to output a certain amount of each genre to the console,
here is my code, I can’t understand where the error is
genres = ['Comedy','Comedy','Comedy','Comedy','Comedy','Comedy','Comedy', 'Dramma','Dramma','Dramma','Dramma','Dramma','Dramma', 'Action','Action','Action','Action','Action','Action','Action','Action','Action','Action','Action','Action','Action']
N = 3
check = []
COUNT = 0
def filter_number(genre, N, count):
if genre not in check:
check.append(genre)
count = 1
return True
if genre in check and count <= N:
count += 1
return True
for genre in genres:
if filter_number(genre, N, COUNT):
print(genre)
genres = ['какие-то жанры']
N = # какое-то число
def filter()
#какой-то код для фильтрации
for genre in genres:
if filter( genre, N):
print(genre)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question