# Problem 5 - Twitter Sentiment Analysis

## Problem 5 - Twitter Sentiment Analysis:

How Can I Colve It?

You need to be more specific, since this course has been finished a long time ago.
Also state how you already tried to solve it, and what’s the problem.

I am doing this Calculate the Sad tweet:

# store the final answer in this variable

number_of_happy_tweets = 0

# perform the calculations here

for i in tweets:
for word in i:
if word == happy_words:
print(word)

i am kinda understand the logic but cant implement it

You need to count them, not print.

I assume `i` variable represents your tweet, but I’m gonna call it `tweet` for clarity.

`for word in tweet` doesn’t iterate over the words, but over the letters. To do so you would have to `split()` the single tweet. But that won’t work anyway.

Bold-hinted text:
You need to iterate over the words from happy_words list. if the word is in tweet then don’t print it, but increase the number_of_happy_tweets by 1. Also you can break the loop to avoid counting the same tweet more than one time.

# store the final answer in this variable

number_of_happy_tweets = 0

# perform the calculations here

for word in happy_words:
if word in tweets:
number_of_happy_tweets =+ 1

It print the word but doesnt store in a varible and count them

1. You either removed or didn’t copy the `for` loop that iterates over `tweets`.
2. Why do you check `if word` is `in tweets`. You need to check in single `tweet`.

you before said that i cant iterate the tweet over the word but letter…so how can i iterate over word?

1. iterate over `tweets` (so you get `tweet`)
2. foreach `tweet` iterate over `happy_words` (so you get `word`)
3. foreach `word` check if this `word` is inside the `tweet`
3.1. if it is, then the `tweet` contains happy `word`, so count it

Can’t make it easier without giving you the solution away.

# store the final answer in this variable

number_of_happy_tweets = 0

# perform the calculations here

for tweet in tweets:
for word in happy_words:
if word in tweet:
number_of_happy_tweets =+ 1

Is It Ok? But It Shown 1 Word Though it has many happy words

Done…Thank You So Much

Are You JOvian Official Person. I have To Ask Something About Course?

No, I’m not. You would have to ask @vishal since he seems like the guy responsible for contacts with community.