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 send a object and its value to the garbage collection?
What are the difference between python and java?
How do you sort a list in reverse order in python?
Explain about indexing and slicing operation in sequences?
What is lambda in Python?
How is numpy different from scipy?
What is the purpose of the pythonpath environment variable?
Can I use Python instead of PHP?
How do you sort a list in descending in python?
what is random module will do in python and what are the functions we can apply on random module
Why is python called python?
Explain me what is the purpose of doc strings in python?