INNER CODE UNIT · Python

interested_user_count

ShawhinT/YouTube-Blog · python-quickstart/my-script.py:144

def interested_user_count(user_list, topic):
    """
        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)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…