data-science-from-scratch icon indicating copy to clipboard operation
data-science-from-scratch copied to clipboard

introduction coding for FINDING KEY CONNECTORS

Open awb25 opened this issue 7 years ago • 1 comments

Hi, Should the code: for i, j in friendships: # this works because users[i] is the user whose id is i users[i]["friends"].append(users[j]) # add i as a friend of j users[j]["friends"].append(users[i]) # add j as a friend of i

be: users[i]["friends"].append(users[j]['id']) users[j]["friends"].append(users[i]['id']) otherwise the friends list fills with dicts and becomes unwieldy

thanks

andrew

awb25 avatar Jun 14 '18 10:06 awb25

Hi, I agrees with Andrew(awb25). if we want to add only id's of friends in the users[0]["friends"] list then dictionary key should be added in append statements after users[j]["id"]

But since in the next phase of the chapter, we need to find mutual friends so the nested dictionary is useful, which is produced by the given code

VikeshBaid avatar Nov 17 '19 10:11 VikeshBaid