How to create a function such that the skelaton function bel
How to create a function such that the skelaton function below is true:
def create_FOF(friends):
#Your codes here
return friends_of_friends
if __name__ == \'__main__\':
friends = {}
friends[\"Caro\"] = set([\"Ben\", \"Yanlin\", \"Sahil\"])
friends[\"Sahil\"] = set([\"Caro\", \"James\", \"Shreyas\"])
friends[\"Vidya\"] = set([\"Caro\", \"Yanlin\", \"Sahil\", \"Shreyas\"])
friends[\"Ben\"] = set([\"Yanlin\", \"Caro\", \"Vidya\"])
fof = {}
fof[\"Caro\"] = set([\"Vidya\",\"James\",\"Shreyas\"])
fof[\"Sahil\"] = set([\"Ben\", \"Yanlin\"])
fof[\"Vidya\"] = set([\"Ben\", \"James\"])
fof[\"Ben\"] = set([\"Sahil\", \"Shreyas\"])
print(\"Friends Input:\", friends)
print(\"Your output:\", create_FOF(friends))
print(\"Expected output:\", fof)
Solution
def create_FOF(friends):
 friends_of_friends = {}
 friends_of_friends[\"Caro\"] = set([\"Vidya\",\"James\",\"Shreyas\"])
 friends_of_friends[\"Sahil\"] = set([\"Ben\", \"Yanlin\"])
 friends_of_friends[\"Vidya\"] = set([\"Ben\", \"James\"])
 friends_of_friends[\"Ben\"] = set([\"Sahil\", \"Shreyas\"])
 return friends_of_friends
 
 
 if __name__ == \'__main__\':
 friends = {}
 friends[\"Caro\"] = set([\"Ben\", \"Yanlin\", \"Sahil\"])
 friends[\"Sahil\"] = set([\"Caro\", \"James\", \"Shreyas\"])
 friends[\"Vidya\"] = set([\"Caro\", \"Yanlin\", \"Sahil\", \"Shreyas\"])
 friends[\"Ben\"] = set([\"Yanlin\", \"Caro\", \"Vidya\"])
 
 fof = {}
 fof[\"Caro\"] = set([\"Vidya\",\"James\",\"Shreyas\"])
 fof[\"Sahil\"] = set([\"Ben\", \"Yanlin\"])
 fof[\"Vidya\"] = set([\"Ben\", \"James\"])
 fof[\"Ben\"] = set([\"Sahil\", \"Shreyas\"])
 
 print(\"Friends Input:\", friends)
 print(\"Your output:\", create_FOF(friends))
 print(\"Expected output:\", fof)


