Given a string, and we have to print the EVEN length words in Python.
Example:
Input:
str: Python is a programming language
Output:
EVEN length words:
Python
is
language
Logic:
- To print the EVEN length words, we have to check length of each word.
- For that, first of all, we have to extract the words from the string and assigning them in a list.
- Iterate the list using loop.
- Count the length of each word, and check whether length is EVEN (divisible by 2) or not.
- If word's length is EVEN, print the word.
Program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer