Python Exercises: Count lowercase letters in a list of words
Python List: Exercise - 274 with Solution
Write a Python program to count the lowercase letters in a given list of words.
In the Code tab is a function which is meant to return how many uppercase letters there are in a list of various words. Fix the list comprehension so that the code functions normally!.
Sample Data:
(["Red", "Green", "Blue", "White"]) -> 13
(["SQL", "C++", "C"]) -> 0
Sample Solution-1:
Python Code:
def test(text):
return sum([el.islower() for word in text for el in word])
text = ["Red", "Green", "Blue", "White"]
print("Original list of words:", text)
print("Count the lowercase letters in the said list of words:")
print(test(text))
text = ["SQL", "C++", "C"]
print("Original list of words:", text)
print("Count the lowercase letters in the said list of words:")
print(test(text))
Sample Output:
Original list of words: ['Red', 'Green', 'Blue', 'White'] Count the lowercase letters in the said list of words: 13 Original list of words: ['SQL', 'C++', 'C'] Count the lowercase letters in the said list of words: 0
Flowchart:

Visualize Python code execution:
The following tool visualize what the computer is doing step-by-step as it executes the said program:
Sample Solution-2:
Python Code:
def test(text):
return sum(map(str.islower, str(text)))
text = ["Red", "Green", "Blue", "White"]
print("Original list of words:", text)
print("Count the lowercase letters in the said list of words:")
print(test(text))
text = ["SQL", "C++", "C"]
print("Original list of words:", text)
print("Count the lowercase letters in the said list of words:")
print(test(text))
Sample Output:
Original list of words: ['Red', 'Green', 'Blue', 'White'] Count the lowercase letters in the said list of words: 13 Original list of words: ['SQL', 'C++', 'C'] Count the lowercase letters in the said list of words: 0
Flowchart:

Visualize Python code execution:
The following tool visualize what the computer is doing step-by-step as it executes the said program:
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous Python Exercise: Divide a list of integers with the same sum value.
Next Python Exercise: Sum of all list elements except current element.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
Python: Tips of the Day
Returns True if the provided function returns True for every element in the list, False otherwise:
Example:
def tips_every(lst, fn=lambda x: x): return all(map(fn, lst)) print(tips_every([2, 4, 3], lambda x: x > 1)) print(tips_every([1, 2, 3]))
Output:
True True
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises