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 |
Should I learn c++ or python?
How do I find the current module name?
What is a singleton python?
Explain me what is a built-in function that python uses to iterate over a number sequence?
Which is better c++ or java or python?
How do I run python on linux?
What are the differences between pass and continue?
What does file flush mean?
How can files be deleted in python?
How to display the contents of the text file in reverse order?
How are classes created in python?
What is scheduling in threading?