data-science-from-scratch
data-science-from-scratch copied to clipboard
most_common_interests_with(user_id) from Python 3 Introductions file
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.
Agree, the former assumes integers are subscriptable @snooze good catch!