Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How do I create a variable number of variables?

814


What is the dictionary in Python?

829


Do while loops python?

785


Explain the use of decorators?

820


Explain python’s parameter-passing mechanism?

878


Can I make games with python?

759


How to get class name of an instance in Python?

851


What is n in python?

773


What will be the output of ['!!welcome!!']*2?

934


Is nan in python pandas?

755


How to install python and prepare environment?

852


Explain how can you make a Python Script executable on Unix?

913


What is the difference between old style and new style classes in python?

811


How to write a text from from another text file in python ?

850


Explain the interpretation in python?

837