Last active
May 30, 2022 10:13
-
-
Save Codehunter-py/e7ee9c49a95cf0fa965fd70562b8cbe8 to your computer and use it in GitHub Desktop.
The long_words function returns all words that are at least 7 characters. Fill in the regular expression to complete this function.
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
import re | |
def long_words(text): | |
pattern = r"\w{7,}" | |
result = re.findall(pattern, text) | |
return result | |
print(long_words("I like to drink coffee in the morning.")) # ['morning'] | |
print(long_words("I also have a taste for hot chocolate in the afternoon.")) # ['chocolate', 'afternoon'] | |
print(long_words("I never drink tea late at night.")) # [] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment