Count lowercase letters in a file

EasyFile Handling Programs · 28 of 38

Write a Python program to count lowercase letters in a file.

Advertisement
Output
14

Approach

  1. sum(ch.islower() for ch in text).

Solution

Python
with open("story.txt", "w") as f:    f.write("Learn Python At SQA Tools\n") with open("story.txt") as f:    print(sum(ch.islower() for ch in f.read()))
Output
14
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More file handling programs

← All 38 File Handling Programs