473,394 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

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!!!!!!" ;-)
Jul 18 '05 #1
0 1008

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Timothy Babytch | last post by:
Hi all. I have a list that looks like , , ] I try to make it flat one: How can I archieve such an effect with list comprehension? Two cycles did the job, but that way did not look pythonic.....
4
by: slick_shoes | last post by:
What would be the best way to switch program flow based on a string the user enters? I found out the hard way that char*'s can't be used in a switch statement, so i've resorted to stringing if-else...
270
by: Jatinder | last post by:
I found these questions on a web site and wish to share with all of u out there,Can SomeOne Solve these Porgramming puzzles. Programming Puzzles Some companies certainly ask for these...
67
by: Bob Powell | last post by:
To whom it may concern: I find the recent articles in various trade publications a little disturbing due to the lack of PostgrSQL mention. I continue to see articles about how IBM may be...
2
by: Tim_Mac | last post by:
hi, i'm referring to System.Globalization.TextInfo.ToTitleCase(string s) and it works fine if you pass in an all lower or mixed case string. however i am trying to make amends for data entry staff...
6
by: Jim Showalter | last post by:
I'm trying to write code that gets fixed-length strings from the user and then stores them in a linked list. Here's the definition of my list node: struct node {char str; struct node* next; };...
4
by: Mark Rae | last post by:
Hi, Is it possible to create a case-insensitive List<stringcollection? E.g. List<stringMyList = new List<string>; MyList.Add("MyString"); So that:
9
by: Joseph Turian | last post by:
I was given code that was written for python 2.5, and uses simple functions like 'all' which are not present in 2.4 I want to make the code 2.4 compatible. What is the best way to do this? If I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.