Jun-12-2019, 11:54 AM
(This post was last modified: Jun-12-2019, 11:54 AM by pythonias2019.)
Hi, I have a list comprised of a tweet and score.
I'd like to split the tweet into words and assign the total score of the tweet to each word.
Any help is much appreciated, new to Python! Thanks
Desired output:
I'd like to split the tweet into words and assign the total score of the tweet to each word.
Any help is much appreciated, new to Python! Thanks
Tweet_list = [('You better believe you're beautiful', 3),('Happy Birthday to my friends',4)] def word_sentiment(): list_words = [] for tweet in tweet_list: for word in tweet.split(" "): list_words.append((word)) return list_words
Desired output:
Output: [('You',3) ('better',3) (believe',3) ('you're',3) ('beautiful',3) ('Happy',4) ('Birthday',4) ('to',4) ('my',4) ('friends',4) ]