Filter and order tweets by polarity values
Level: Intermediate (score: 3)
In this Bite we collected some random tweets and populated a list of named tuples of text and a polarity rating which we got using TextBlob
, an awesome module that makes it easy to do sentiment analysis.
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 (and type hints).
Enjoy and keep calm and code in Python!