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 |
What is tail recursion?
How do I run a python script?
What is a dataframe in python?
What is the difference between a shallow copy and deep copy?
What is lambda?
Explain all the file processing modes supported by python?
How long can an identifier be in python?
Is python object oriented?
What is a function for flatten an irregular list of lists?
Why is numpy so fast?
How to find the index of an item given a list containing it in python?
Explain how to make Forms in python.