WSQ17. The movies

Before saying anything about the coding, I have to say that this was the most difficult program since I entered this course, I saw it as a challenge and after 5 hours I managed to complete it.

For the program I created three functions.

The first function is in charge of taking the text file a making a dictionary where the keys are the name of the movies and the value of each key is a list containing the name of the actors who acted in that movie.

The second function called check_movies receives as a parameter 2 movies and then calls the first function to get the main dictionary, and creates a second dictionary but rearenged to have the name of the actors as keys and the movies  in which they have participated as the values for each key, Then the function goes over each key of this second dictionary checking the lenght of the list of movies assigned for the actor to decide to which category of the three the actor belongs.

A third function called check_coactors receives as a paremeter the name of an actor and then, as in the second function, it calls the first function to get the main dictionary. After that, it creates a list containing the movies where the actor has participated, then, it creates a list containg the actors of each of these movies, and finally creates a dictionary to check that none of this actors is repeated in this list, and the keys of the dictionaries, which are the actors are passed to a third list that is going to be showed to the user

After these three function I created the interface with the user to check what is he going to request.

Here is an screenshot of how it loks the program running on the terminal:

Here is my code for the solution:

https://github.com/Manuelmv94/TC1014/blob/master/wsq17.py

 

CC BY 4.0 WSQ17. The movies by Manuel Madrigal is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.