please code in python 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))

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

please code in python

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))

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
ListBox
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education