forked from RoksYz/CS1301xIII---Data-Structures
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStars.py
37 lines (32 loc) · 1.87 KB
/
Stars.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def stars(movies,tvshows):
Newdict = {}
for keys,values in movies.items():
for items in values:
if items not in Newdict:
Newdict[items]=[keys]
else:
Newdict[items]+=[keys]
for keys,values in tvshows.items():
for items in values:
if items not in Newdict:
Newdict[items]=[keys]
else:
Newdict[items]+=[keys]
for key,values in Newdict.items():
values = values.sort()
return Newdict
#print (although the order of the keys may vary):
#
#{'Portia de Rossi': ['Arrested Development'], 'Will Ferrell': ['The Lego Movie'], 'Yvette Brown': ['Community'], 'Rebel Wilson': ['How to Be Single'], 'Danny Pudi': ['Community'], 'Elizabeth Banks': ['30 Rock', 'The Lego Movie'], 'Alec Baldwin': ['30 Rock'], 'Alison Brie': ['Community', 'How to Be Single', 'The Lego Movie'], 'Tina Fey': ['30 Rock'], 'Dakota Johnson': ['How to Be Single'], 'Joel McHale': ['Community'], 'Jack McBrayer': ['30 Rock'], 'Tracy Morgan': ['30 Rock'], 'Donald Glover': ['Community'], 'Will Arnett': ['Arrested Development', 'The Lego Movie'], 'Jason Bateman': ['Arrested Development']}
movies = {"How to Be Single": ["Alison Brie", "Dakota Johnson",
"Rebel Wilson"],
"The Lego Movie": ["Will Arnett", "Elizabeth Banks",
"Alison Brie", "Will Ferrell"]}
tvshows = {"Community": ["Alison Brie", "Joel McHale",
"Danny Pudi", "Yvette Brown",
"Donald Glover"],
"30 Rock": ["Tina Fey", "Tracy Morgan", "Jack McBrayer",
"Alec Baldwin", "Elizabeth Banks"],
"Arrested Development": ["Jason Bateman", "Will Arnett",
"Portia de Rossi"]}
print(stars(movies, tvshows))