Python programming problem

Hello everybody,
I want to write a program for the following problem:
Any help for solving this problem is highly appreciated.
Problem: In a survey, people interested in watching movies were asked to write three of their favorite genres. They are given 6 different genres to choose from, including: Horror, Romance, Comedy, History, Adventure, Action.
Write a program that takes the number of people and then each person’s name with one’s favorite genres. Print the name of each genre and the number of people interested in that genre in the order of the most interested in the output.
(If the level of interest in the different genres is the same, print the output based on the alphabetical order.)
If a genre is not selected, set it to zero and print the name and number 0 in the output.
Sample input:
2
John Horror Romance Comedy
Laura Adventure Action History
Sample output:
Action : 1
Adventure : 1
Comedy : 1
History : 1
Horror : 1
Romance : 1

@adpy How far have you gotten? What do you have so far?

Hi,
you really want to add some data validation in this one :smiley:

movie_genre = {
    'Action': 0,
    'Adventure': 0,
    'Comedy': 0,
    'History': 0,
    'Horror': 0,
    'Romance': 0
}


def update_genre_list(raw_user_input):
    # no use of a name, so skip the 0 index after split
    for i in raw_user_input.split()[1:]:
        global movie_genre
        movie_genre[i] += 1


def print_final_list(genres_dict):
    # sort by number descending and by name ascending
    sorted_genres = sorted(genres_dict.items(), key=lambda x: (-x[1], x[0]))
    for genre in sorted_genres:
        print(f'{genre[0]}: {genre[1]}')


no_of_people = int(input("Provide number of people to test: "))
print(list(movie_genre))

for person in range(no_of_people):
    answers = input("Provide your name followed by"
                    "fav movie genre from above list: ")
    update_genre_list(answers)

print_final_list(movie_genre)

Many thanks for your code :tulip: :100:

There is a little problem in this code, i.e. texts like “Provide number of people to test” or “Provide your name followed by fav movie genre from above list” should not be come out in the code. Actually, the user should only type the sample input as given above without any extra text. Would you edit this one?