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.
Answer / mahesh
len([c for l in open('foo.txt') for c in l if c.isupper()])
| Is This Answer Correct ? | 0 Yes | 0 No |
How to walk through a list in a sorted order without sorting the actual list?
What is string replication operator in python?
What is the meaning of def in python?
Mention the use of // operator in Python?
How to find whether string is alphanumeric or not?
Do sheeps sleep?
What is difference between raw_input and input in python?
How do you calculate the length of a string?
What are python variables?
What do (lambda) function closures capture in python?
Is nodejs faster than python?
What does len () mean in python?