We use Python 3.6

go back Level: Intermediate (img: IM / score: 3) level Bite 81. Filter and order tweets by polarity values

15 out of 15 users completed this Bite ...
Will you be Pythonista #16 to crack this Bite?
Average Bite difficulty 1-10 rating: 4.5
» Up for a challenge? 💪

In this Bite we collected some random tweets and populated a list of namedtuples of text and a polarity rating which we got using TextBlob, an awesome module that makes it easy to do sentiment analysis (we used it for our PCC07):

  blob = TextBlob(tweet)
  polarity = blob.sentiment.polarity

A polarity of < 0 indicates a negative sentiment, > 0 a positive one.

In this Bite we practice list comprehensions and sorting. Complete the two functions below following their docstrings. Enjoy and keep calm and code in Python!

Github login button