Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need urgent help with following Python Question: A tweet is a string that is between 1 and 280 characters long (inclusive). A username is a

Need urgent help with following Python Question:

A tweet is a string that is between 1 and 280 characters long (inclusive). A username is a string of letters and/or digits that is between 1 and 14 characters long (inclusive). A username is mentioned in a tweet by including @username in the tweet (notice the username does not include the @ symbol). A retweet is way to share another user's tweet, and can be identified by the string RT, followed by the original username who tweeted it.

Your job is to fill in the function count_retweets_by_username so that it returns a frequency dictionary that indicates how many times each retweeted username was retweeted.

tweets = ["This is great! RT @fakeuser: Can you believe this?", "It's the refs! RT @dubsfan: Boo the refs and stuff wargarbal", "That's right RT @ladodgers: The dodgers are destined to win the west!", "RT @sportball: That sporting event was not cool", "This is just a tweet about things @person, how could you", "RT @ladodgers: The season is looking great!", "RT @dubsfan: I can't believe it!", "I can't believe it either! RT @dubsfan: I can't believe it"]

def count_retweets_by_username(tweet_list): """ (list of tweets) -> dict of {username: int} Returns a dictionary in which each key is a username that was retweeted in tweet_list and each value is the total number of times this username was retweeted. """ # write code here and update return statement with your dictionary return {}

# allow this code to work by implementing count_retweets_by_username function above print(count_retweets_by_username(tweets))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Online Market Research Cost Effective Searching Of The Internet And Online Databases

Authors: John F. Lescher

1st Edition

0201489295, 978-0201489293

More Books

Students also viewed these Databases questions

Question

How do we organise for international logistics?

Answered: 1 week ago

Question

What are the logistics implications of internationalisation?

Answered: 1 week ago