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.



Write a one-liner that will count the number of capital letters in a file. Your code should work eve..

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

Post New Answer

More Python Interview Questions

How to send a object and its value to the garbage collection?

1 Answers  


What are the difference between python and java?

1 Answers  


How do you sort a list in reverse order in python?

1 Answers  


Explain about indexing and slicing operation in sequences?

1 Answers  


What is lambda in Python?

1 Answers  


How is numpy different from scipy?

1 Answers  


What is the purpose of the pythonpath environment variable?

1 Answers  


Can I use Python instead of PHP?

1 Answers  


How do you sort a list in descending in python?

1 Answers  


what is random module will do in python and what are the functions we can apply on random module

1 Answers  


Why is python called python?

1 Answers  


Explain me what is the purpose of doc strings in python?

1 Answers  


Categories