Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > lowering the case of strings in list -- WAS: (No subject)

Reply
Thread Tools

lowering the case of strings in list -- WAS: (No subject)

 
 
Brian van den Broek
Guest
Posts: n/a
 
      12-16-2004
Mark Devine said unto the world upon 2004-12-16 10:49:
> Hi 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.
>
> The list is like so: 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']
>
> and what I want is: 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']
>
> Are there any defined method within any known modules to do this in
> one go?
>
> Thanks in advance


Hi Mark,

I'm learning, too, so no bets this is best, but does this meet your needs:

..>>> def lower_list_o_strings(l):
nl = []
for s in l:
nl.append(s.lower())
return nl

..>>> l = ['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']
..>>> lower_list_o_strings(l)
['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']


Best,

Brian vdB

PS "No subject" is only marginally better than "HELP!!!!!!"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lowering Of Graphite Rods Into Reactor Core Divvy Bollocks C++ 1 03-30-2006 01:53 PM
lowering ruby's reach jm Ruby 8 08-03-2005 11:40 PM
Lowering the resolution to improve quality VR Digital Photography 17 01-06-2005 01:31 AM
Lowering Processing Overhead Radley Cisco 0 01-24-2004 04:30 PM
lowering picture quality kjk Digital Photography 10 01-12-2004 01:25 AM



Advertisments