Write a one-liner that will count the number of capital letters in a file. Your code should work even if the file is too big to fit in memory.

By ayush goel in 22 Sep 2023 | 04:13 pm
ayush goel

ayush goel

Student
Posts: 346
Member since: 21 Sep 2023

Write a one-liner that will count the number of capital letters in a file. Your code should work even if the file is too big to fit in memory.

22 Sep 2023 | 04:13 pm
0 Likes
divas goyal

divas goyal

Student
Posts: 453
Member since: 22 Sep 2023

count = sum(1 for line in open('filename.txt') for char in line if char.isupper())

print(count)


22 Sep 2023 | 06:18 pm
0 Likes

Report

Please describe about the report short and clearly.