INNER CODE UNIT · Python
to
ShawhinT/YouTube-Blog · python-quickstart/my-script.py:146
Function to count number of users interested in an arbitrary topic
"""
count = 0
for user in user_list:
if topic in user["Interests"]:
count = count + 1
return count
# define user list and topic
user_list = [user_dict, new_user_dict]
topic = "Shopping"
# compute interested user count and print it
count = interested_user_count(user_list, topic)
print(f"{count} user(s) interested in {topic}")