[ad_1]
Task: Given a list of movies in the cinema. Starting with index 0, each element in the array is the name of the movie in production on the i-th day. Transform this data by creating a dictionary schedule that for each movie as key stores the list of days when this movie screenings are. For example:
movies = ['Shrek', 'Snow White', 'Cars', 'Cars', 'Shrek', 'Shrek 2'] =>
schedule = {
'Cars': [2, 3],
'Shrek': [0, 4],
'Shrek 2': [5],
'Snow White': [1]}
Remember about case if movie is not in dict already.
Here’s what I have so far, feel like I’m close…
# DO NOT change/shuffle the list
movies = ['Ice Age', 'Taxi', 'Taxi 2', 'The Star Wars', 'Taxi 2', 'Zootopia',
'Zootopia', 'Taxi 2', 'Ice Age', 'Toys Story', 'Ice Age']
schedule = dict()
for day, movie in enumerate(movies):
schedule.update({movie, day})
print(schedule)
[ad_2]