Created
April 10, 2020 17:24
-
-
Save klahrich/1f2d356bfecdd58c23beb6ff4fdbea8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Challenge no 1: you have a list of sentences. What are the top-3 most frequent words (case-insensitive) longer than 3 characters. | |
from collections import Counter | |
sentences = ["This is the first sentence", "My first time was in Havana", "What is it this time", "Time is precious"] | |
words = [word.lower() for sentence in sentences for word in sentence.split()] | |
counter = Counter([word for word in words if len(word) >= 3]) | |
counter.most_common(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment