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 write a text from from another text file in python ?
Can a set be sorted python?
What is python distutils?
What is sphinx in python?
What is pass in Python?
How do you write a simple code in python?
How is a .pyc file different from a .py file?
what does yield function do? what is the difference between return and yield?
How does the ternary operator work in python?
What is a means by “tuple in python”?
What is python __ repr __?
What are global variables in python?