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 Posted / mahesh
len([c for l in open('foo.txt') for c in l if c.isupper()])
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Which version of python is best?
What is set when we have to use?
Whenever python exits, why isn’t all the memory de-allocated?
Why python is popular now?
Is python client or server side?
What ide to use for python?
How do I use strftime in python?
What happens if an error occurs that is not handled in the except block?
How would you convert a string into an int in python?
How will you get a titlecased version of string?
What is an abstract class in python?
What are decorators in python and how do you use them?
How do I know my python version?
What is the mro in python?
How to overload constructors or methods in python?