Your task is to write a python program that will create an ID for all the movies and store it in a dictionary and then print the dictionary. Your
Suppose you are working as a Software Engineer in an online streaming
service. You are given the following tuple where all the information of a
movie is given as [NameOfMove ActorName Actor’sCountry].
my_tuple = ("NoTimeToDie DanielCraige UK", "MissionImpossible TomCruise
USA", "TopGun TomCruise USA", "Troy BradPitt USA", "Skyfall DanielCraige
UK", "TheTheoryOfEveryting EddieRedmayne UK", "FantasticBeast EddieRedmayne
UK", "Seven BradPitt USA")
Your task is to write a python program that will create an ID for all the
movies and store it in a dictionary and then print the dictionary. Your
dictionary should be as expected output and while generating the ID ensure
the following criteria are met. Finally print the dictionary.You do not
need to take any input. Imagine the input is already given.
For the first digit, if country is UK = 1 and USA = 2
Then, if actor is DanielCraige = 01, TomCruise = 02, BradPitt = 03 and
EddieRedmayne = 04
Use the tuple’s index number as the last digit.
Expected Output:
{'USA': [('MissionImpossible', 2021), ('TopGun', 2022), ('Troy', 2033),
('Seven', 2037)], 'UK': [('NoTimeToDie', 1010), ('Skyfall', 1014),
('TheTheoryOfEveryting', 1045), ('FantasticBeast', 1046)]}
Explanation: ID of MissionImpossible is 2021. This actor is from the USA so
the first digit is 2, as the actor is TomCruise so 2nd and 3rd digits are
01 and last digit 1 represents that item is situated at index 1 in the
my_tuple. You must store the movie name and movie ID in a tuple and save
that tuple in a list as the value of the dictionary. You Must Store The ID
as an Integer.
Step by step
Solved in 4 steps with 2 images