Lowercasing Items in a List

Benji York benji at benjiyork.com
Thu Dec 16 16:50:37 CET 2004


Mark Devine wrote:
> I'm brand new to python and I was wondering if anybody knew of a easy
> way to change every character in a list into its lower case form.

How about this:

 >>> commands = ['CLASS-MAP MATCH-ALL cmap1', 'MaTch Ip AnY', 'CLASS-map 
Match-Any cmap2', 'MaTch AnY', 'Policy-map policy1', 'Class cmap1', 
'policy-Map policy2', 'Service-PoLicy policy1', 'claSS cmap2']
 >>> [c.lower() for c in commands]
['class-map match-all cmap1', 'match ip any', 'class-map match-any 
cmap2', 'match any', 'policy-map policy1', 'class cmap1', 'policy-map 
policy2', 'service-policy policy1', 'class cmap2']
--
Benji York



More information about the Python-list mailing list