suggestions for Choosing a data structure for a friendship network

I have to implement a program which analyzes friendship. There will be a text file which will contain group of when user input a name from the group, the program shows who are this person’s friends.
For example, the text file contains,
Erina;Mira; Kyla;
If user inputs Mira it will show other person as her friends..
I need to store the text file data in a data structure.. So what kind of data structure will be suitable for this in python? Should I go for a dictionary??
( The question asks for nested data structure)

>Solution :

Yes a dictionary would be your best bet. You could store the name of the person as the key and the a list of friends as the value. You can then append friends to the list like this:

friends_dict = dict()
friends_dict['john'] = []
$ {'john':['lisa']}

Leave a Reply