Python: Find all five characters long word in a string
33. Find 5-letter Words
Write a Python program to find all five-character words in a string.
Sample Solution:
Python Code:
import re
text = 'The quick brown fox jumps over the lazy dog.'
print(re.findall(r"\b\w{5}\b", text))
Sample Output:
['quick', 'brown', 'jumps']
Pictorial Presentation:
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to extract all words that are exactly five characters long from a given string.
- Write a Python script to search for five-letter words in a text and then output them in a list.
- Write a Python program to find and print all unique five-letter words in a paragraph.
- Write a Python program to count the number of five-letter words in a text and display the result.
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to replace maximum 2 occurrences of space, comma, or dot with a colon.
Next: Write a Python program to find all three, four, five characters long words in a string.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.