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

most_common_interests_with(user_id) from Python 3 Introductions file

Open snooze opened this issue 7 years ago • 1 comments

I think that:

def most_common_interests_with(user_id): return Counter(interested_user_id for interest in interests_by_user_id["user_id"] for interested_user_id in user_ids_by_interest[interest] if interested_user_id != user_id)

Should be:

def most_common_interests_with(user_id): return Counter(interested_user_id for interest in interests_by_user_id[user_id] for interested_user_id in user_ids_by_interest[interest] if interested_user_id != user_id)

Quotes around user_id in third quoted line removed.

snooze avatar Mar 31 '18 16:03 snooze

Agree, the former assumes integers are subscriptable @snooze good catch!

Neshmwaniki avatar Oct 24 '19 02:10 Neshmwaniki