how to delete lowercase words from a string in python

I'm new in python and I'm having some issues doing a simple thing.

I've an array (or list as it's said in python) like this:

 list = [ 'NICE dog' , 'blue FLOWER' , 'GOOD cat' , 'YELLOW caw']

As you see each element of this array contains some words. These words is both lowercase and uppercase.

How I can delete from this array each lowercase words?

For example I'd like to have as result this list:

list = [ 'NICE' , 'FLOWER' , 'GOOD' , 'YELLOW']

Answers


l = [ 'NICE dog' , 'blue FLOWER' , 'GOOD cat' , 'YELLOW caw']

output = [' '.join(w for w in a.split() if w.isupper())  for a in l]
# or:    
output = [' '.join(filter(str.isupper, a.split())) for a in l]

returns:

['NICE', 'FLOWER', 'GOOD', 'YELLOW']

(Don't use list as variable name.)


Need Your Help

Cross-site request forgery Yii ,PHP

security website yii csrf

I am trying to implement CSRF validation in yii . I have written my own class and everything works fine except the fact that my post variable(for the form) does not consist of the token . Am I supp...

ThreadAbortException internal implementation

.net multithreading exception-handling cil

As we all know, .NET Framework provides a little bit specific implementation of ThreadAbortException handling. Means that this exception can not be catch via try-catch-finally block. Taking a littl...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.