<filename>3-Data-Structures/movie_tv_actor/stars.py
# This is a challenging one! The output will be very long as
# you'll be working on some pretty big dictionaries. We don't
# expect everyone to be able to do it, but it's a good chance
# to test how far you've come!
#
# Write a function called stars that takes in two
# dictionaries:
#
# - movies: a dictionary where the keys are movie titles and
#   the values are lists of major performers in the movie. For
#   example: movies["The Dark Knight"] = ["<NAME>",
#   "<NAME>", "<NAME>", "<NAME>"]
# - tvshows: a dictionary where the keys are TV show titles
#   and the values lists of major performers in the show.
#   For example: tvshows["Community"] = ["<NAME>", "Alison
#   Brie", "<NAME>", "<NAME>", "<NAME>"]
#
# The function stars should return a new dictionary. The keys
# of the new dictionary should be the performers' names, and
# the values for each key should be the list of shows and
# movies in which that performer has appeared. Sort the shows
# and movies alphabetically.


# Write your function here!
def stars(movie_dict, tv_dict):
    result = {}
    movie_list = []
    tv_list = []

    for movie in movie_dict:
        movie_list.append(movie)

    for tv in tv_dict:
        tv_list.append(tv)

    movie_list.sort()
    tv_list.sort()

    for tv in tv_list:
        for actor in tv_dict[tv]:
            result[actor] = []

    for movie in movie_list:
        for actor in movie_dict[movie]:
            result[actor] = []

    for tv in tv_list:
        for actor in tv_dict[tv]:
            result[actor].append(tv)

    for movie in movie_list:
        for actor in movie_dict[movie]:
            result[actor].append(movie)

    return result

# Below are some lines of code that will test your function.
# You can change the value of the variable(s) to test your
# function with different inputs.
#
# If your function works correctly, this will originally
# print (although the order of the keys may vary):
#
# {'<NAME>': ['Arrested Development'], '<NAME>': ['The Lego Movie'], '<NAME>': ['Community'], '<NAME>': ['How to Be Single'], '<NAME>': ['Community'], 'Elizabeth Banks': ['30 Rock', 'The Lego Movie'], '<NAME>': ['30 Rock'], '<NAME>': ['Community', 'How to Be Single', 'The Lego Movie'], '<NAME>': ['30 Rock'], '<NAME>': ['How to Be Single'], '<NAME>': ['Community'], '<NAME>': ['30 Rock'], '<NAME>': ['30 Rock'], '<NAME>': ['Community'], '<NAME>': ['Arrested Development', 'The Lego Movie'], '<NAME>': ['Arrested Development']}

movies = {"How to Be Single": ["<NAME>", "<NAME>",
                               "<NAME>"],
          "The Lego Movie": ["<NAME>", "Elizabeth Banks",
                             "<NAME>", "<NAME>"]}
tvshows = {"Community": ["<NAME>", "<NAME>",
                         "<NAME>", "<NAME>",
                         "<NAME>"],
           "30 Rock": ["<NAME>", "<NAME>", "<NAME>",
                       "<NAME>", "Elizabeth Banks"],
           "Arrested Development": ["<NAME>", "<NAME>",
                                    "Portia de Rossi"]}
print(stars(movies, tvshows))

<filename>3-Data-Structures/movie_tv_actor/stars.py
# This is a challenging one! The output will be very long as
# you'll be working on some pretty big dictionaries. We don't
# expect everyone to be able to do it, but it's a good chance
# to test how far you've come!
#
# Write a function called stars that takes in two
# dictionaries:
#
# - movies: a dictionary where the keys are movie titles and
#   the values are lists of major performers in the movie. For
#   example: movies["The Dark Knight"] = ["<NAME>",
#   "<NAME>", "<NAME>", "<NAME>"]
# - tvshows: a dictionary where the keys are TV show titles
#   and the values lists of major performers in the show.
#   For example: tvshows["Community"] = ["<NAME>", "Alison
#   Brie", "<NAME>", "<NAME>", "<NAME>"]
#
# The function stars should return a new dictionary. The keys
# of the new dictionary should be the performers' names, and
# the values for each key should be the list of shows and
# movies in which that performer has appeared. Sort the shows
# and movies alphabetically.


# Write your function here!
def stars(movie_dict, tv_dict):
    result = {}
    movie_list = []
    tv_list = []

    for movie in movie_dict:
        movie_list.append(movie)

    for tv in tv_dict:
        tv_list.append(tv)

    movie_list.sort()
    tv_list.sort()

    for tv in tv_list:
        for actor in tv_dict[tv]:
            result[actor] = []

    for movie in movie_list:
        for actor in movie_dict[movie]:
            result[actor] = []

    for tv in tv_list:
        for actor in tv_dict[tv]:
            result[actor].append(tv)

    for movie in movie_list:
        for actor in movie_dict[movie]:
            result[actor].append(movie)

    return result

# Below are some lines of code that will test your function.
# You can change the value of the variable(s) to test your
# function with different inputs.
#
# If your function works correctly, this will originally
# print (although the order of the keys may vary):
#
# {'<NAME>': ['Arrested Development'], '<NAME>': ['The Lego Movie'], '<NAME>': ['Community'], '<NAME>': ['How to Be Single'], '<NAME>': ['Community'], 'Elizabeth Banks': ['30 Rock', 'The Lego Movie'], '<NAME>': ['30 Rock'], '<NAME>': ['Community', 'How to Be Single', 'The Lego Movie'], '<NAME>': ['30 Rock'], '<NAME>': ['How to Be Single'], '<NAME>': ['Community'], '<NAME>': ['30 Rock'], '<NAME>': ['30 Rock'], '<NAME>': ['Community'], '<NAME>': ['Arrested Development', 'The Lego Movie'], '<NAME>': ['Arrested Development']}

movies = {"How to Be Single": ["<NAME>", "<NAME>",
                               "<NAME>"],
          "The Lego Movie": ["<NAME>", "Elizabeth Banks",
                             "<NAME>", "<NAME>"]}
tvshows = {"Community": ["<NAME>", "<NAME>",
                         "<NAME>", "<NAME>",
                         "<NAME>"],
           "30 Rock": ["<NAME>", "<NAME>", "<NAME>",
                       "<NAME>", "Elizabeth Banks"],
           "Arrested Development": ["<NAME>", "<NAME>",
                                    "Portia de Rossi"]}
print(stars(movies, tvshows))

# This is a challenging one! The output will be very long as # you'll be working on some pretty big dictionaries. We don't # expect everyone to be able to do it, but it's a good chance # to test how far you've come! # # Write a function called stars that takes in two # dictionaries: # # - movies: a dictionary where the keys are movie titles and #   the values are lists of major performers in the movie. For #   example: movies["The Dark Knight"] = ["<NAME>", #   "<NAME>", "<NAME>", "<NAME>"] # - tvshows: a dictionary where the keys are TV show titles #   and the values lists of major performers in the show. #   For example: tvshows["Community"] = ["<NAME>", "Alison #   Brie", "<NAME>", "<NAME>", "<NAME>"] # # The function stars should return a new dictionary. The keys # of the new dictionary should be the performers' names, and # the values for each key should be the list of shows and # movies in which that performer has appeared. Sort the shows # and movies alphabetically. # Write your function here! # Below are some lines of code that will test your function. # You can change the value of the variable(s) to test your # function with different inputs. # # If your function works correctly, this will originally # print (although the order of the keys may vary): # # {'<NAME>': ['Arrested Development'], '<NAME>': ['The Lego Movie'], '<NAME>': ['Community'], '<NAME>': ['How to Be Single'], '<NAME>': ['Community'], 'Elizabeth Banks': ['30 Rock', 'The Lego Movie'], '<NAME>': ['30 Rock'], '<NAME>': ['Community', 'How to Be Single', 'The Lego Movie'], '<NAME>': ['30 Rock'], '<NAME>': ['How to Be Single'], '<NAME>': ['Community'], '<NAME>': ['30 Rock'], '<NAME>': ['30 Rock'], '<NAME>': ['Community'], '<NAME>': ['Arrested Development', 'The Lego Movie'], '<NAME>': ['Arrested Development']}