# Title: Project 1 - Social Network Besties # Author: Rory Healy # Date created - 17th April 2019 def friend_besties(individual, bestie_dict): '''Takes an individual's name, stored as a string "individual", and the dictionary of sets of immediate friends, stored as a dictionary "bestie_dict". Returns a sorted list of the individual's degree-one friends.''' # Creates an empty list, best_friends, and adds immediate friends of the # individual to the list. best_friends = [] for item in list(bestie_dict.items()): # Define the current person and their friends in the for loop. current_person = item[0] current_friends = item[1] if len(current_friends) == 0: return best_friends else: if current_person == individual: for friends in current_friends: best_friends.append(friends) return sorted(best_friends)