Whittle it on down

DFS nospam at dfs.com
Thu May 5 00:58:12 EDT 2016


Want to whittle a list like this:

[u'Espa\xf1ol', 'Health & Fitness Clubs (36)', 'Health Clubs & 
Gymnasiums (42)', 'Health Fitness Clubs', 'Name', 'Atlanta city guide', 
'edit address', 'Tweet', 'PHYSICAL FITNESS CONSULTANTS & TRAINERS', 
'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 
'www.custombuiltpt.com/', 'RACQUETBALL COURTS PRIVATE', 
'www.lafitness.com', 'GYMNASIUMS', 'HEALTH & FITNESS CLUBS', 
'www.lafitness.com', 'HEALTH & FITNESS CLUBS', 'www.lafitness.com', 
'PERSONAL FITNESS TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'EXERCISE & 
PHYSICAL FITNESS PROGRAMS', 'FITNESS CENTERS', 'HEALTH CLUBS & 
GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'PERSONAL FITNESS TRAINERS', 
'5', '4', '3', '2', '1', 'Yellow Pages', 'About Us', 'Contact Us', 
'Support', 'Terms of Use', 'Privacy Policy', 'Advertise With Us', 
'Add/Update Listing', 'Business Profile Login', 'F.A.Q.']

down to

['PHYSICAL FITNESS CONSULTANTS & TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 
'HEALTH CLUBS & GYMNASIUMS', 'RACQUETBALL COURTS PRIVATE', 'GYMNASIUMS', 
'HEALTH & FITNESS CLUBS', 'HEALTH & FITNESS CLUBS',  'PERSONAL FITNESS 
TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'EXERCISE & PHYSICAL FITNESS 
PROGRAMS', 'FITNESS CENTERS', 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS 
& GYMNASIUMS', 'PERSONAL FITNESS TRAINERS']



Want to keep all elements containing only upper case letters or upper 
case letters and ampersand (where ampersand is surrounded by spaces)

Is it easier to extract elements meeting those conditions, or remove 
elements meeting the following conditions:

* elements with a lower-case letter in them
* elements with a number in them
* elements with a period in them

?


So far all I figured out is remove items with a period:
newlist = [ x for x in oldlist if "." not in x ]


Thanks for help, python gurus.



More information about the Python-list mailing list