Python: Cut out words of 3 to 6 characters length from a given sentence not more than 1024 characters
Python Basic - 1: Exercise-60 with Solution
Internet search engine giant, such as Google accepts web pages around the world and classify them, creating a huge database. The search engines also analyze the search keywords entered by the user and create inquiries for database search. In both cases, complicated processing is carried out in order to realize efficient retrieval, but basics are all cutting out words from sentences.
Write a Python program to cut out words of 3 to 6 characters length from a given sentence not more than 1024 characters.
English sentences consisting of delimiters and alphanumeric characters are given on one line.
Output a word delimited by one space character on one line.
print("Input a sentence (1024 characters. max.)") yy = input() yy = yy.replace(",", " ") yy = yy.replace(".", " ") print("3 to 6 characters length of words:") print(*[y for y in yy.split() if 3 <= len(y) <= 6])
Input a sentence (1024 characters. max.) The quick brown fox 3 to 6 characters length of words: The quick brown fox
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program that compute the area of the polygon . The vertices have the names vertex 1, vertex 2, vertex 3, ... vertex n according to the order of edge connections.
Next: Write a python program to find heights of the top three building in descending order from eight given buildings.
What is the difficulty level of this exercise?
- New Content published on w3resource :
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework