View the step-by-step solution to:


Subject is Python.

Please help to make a function load_profiles: (TextIO) -> Tuple[Dict[str,

List[str]], Dict[str, List[str]]

The parameter refers to a file that is open for reading. The data in the file is in the Data Format described above. This function must build a "person to friends" dictionary and a "person to clubs" dictionary with the data from the open file, and return a two-item tuple containing the dictionaries (the first item is the "person to friends" dictionary and the second item is the "person to clubs" dictionary). Note: it may turn out that person A has person B in their friends list, while person B does not have person A in their friends list.


  • If a person does not have any friends, then they must not appear in the "person to friends" dictionary. That is, if a person is only listed as a friend and does not have friends of their own, they should not appear as a key in the dictionary.
  • Similarly, if a person is not a member of any clubs, then they must not appear in the "person to clubs" dictionary.


Data Format

The profile information for people in the social network is stored in a file. Your program will need to read the data from the file and process it.

The file contains 0 or more profiles. Each profile has the following format:

  • 1 line containing the person's name
  • then 0 or more lines containing the names of this person's clubs (one club per line)
  • and finally 0 or more lines containing the names of this person's friends (one friend per line)

The profile file format adheres to the following rules:

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Let our 24/7 Computer Science tutors help you get unstuck! Ask your first question.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors