473,388 Members | 1,377 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,388 software developers and data experts.

Is there a .tolower() for a string??

Amy
I have a string say

a = "Hello how are YOU"

I want to end up with

a = "hello how are you'

Isn't there a built in method for changing a string to lowercase?

Thanks.
Jul 18 '05 #1
7 10781
>Isn't there a built in method for changing a string to lowercase?

"If you can't find it, it's probably in section two of the library docs."
(Hint: strings are a sequence type.)

- Kef

Jul 18 '05 #2
I have a string say

a = "Hello how are YOU"

I want to end up with

a = "hello how are you'

Isn't there a built in method for changing a string to lowercase?

'aBc'.lower()

'abc'
Jul 18 '05 #3

"Amy" <se*******@hotmail.com> wrote in message
news:7b*************************@posting.google.co m...
I have a string say

a = "Hello how are YOU"

I want to end up with

a = "hello how are you'

Isn't there a built in method for changing a string to lowercase?

Thanks.


a.lower()

Jul 18 '05 #4
Amy wrote:
I have a string say

a = "Hello how are YOU"

I want to end up with

a = "hello how are you'

Isn't there a built in method for changing a string to lowercase?


dir("")

will give you all str attributes. The most promising is lower, so let's try:
a = "LOWER"
a.lower() 'lower' a 'LOWER'

You might not have expected the last outcome. This is because the lower()
method does not change the original string but creates a new one that is
all lowercase. Strings are "immutable", i. e. cannot be changed once they
are created. To get the desired effect, you need to "rebind" a:
a = a.lower()
a

'lower'

Peter
Jul 18 '05 #5
look at .lower()
I hope it helps
AF

"Amy" <se*******@hotmail.com> a écrit dans le message de
news:7b*************************@posting.google.co m...
I have a string say

a = "Hello how are YOU"

I want to end up with

a = "hello how are you'

Isn't there a built in method for changing a string to lowercase?

Thanks.

Jul 18 '05 #6
Dnia 26 Nov 2003 10:57:32 -0800, Amy napisa³(a):
[...]
Isn't there a built in method for changing a string to lowercase?

print ''.lower.__doc__

S.lower() -> string

Return a copy of the string S converted to lowercase.
Read the docs!

--
[ Wojtek Walczak - gminick (at) underground.org.pl ]
[ <http://gminick.linuxsecurity.pl/> ]
[ "...rozmaite zwroty, matowe od patyny dawnosci." ]

Jul 18 '05 #7
Wojtek Walczak <gm*****@hacker.pl> wrote in
news:bq**********@nemesis.news.tpi.pl:
Dnia 26 Nov 2003 10:57:32 -0800, Amy napisa³(a):
[...]
Isn't there a built in method for changing a string to lowercase?
print ''.lower.__doc__ S.lower() -> string

Return a copy of the string S converted to lowercase.
Read the docs!


Also, you could have said 'learn to use the help command, its more
convenient than printing __doc__':
help("".lower)

Help on built-in function lower:

lower(...)
S.lower() -> string

Return a copy of the string S converted to lowercase.


Another command the OP might have found useful would be help(""), or
help(str) which tell you all about the string methods.

--
Duncan Booth du****@rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
Jul 18 '05 #8

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

Similar topics

3
by: qazmlp | last post by:
I was using the following code to convert the string to lowercase. string foo = "Some Mixed Case Text"; transform(foo.begin(), foo.end(), foo.begin(), tolower); I thought the above code is...
13
by: David Rubin | last post by:
I get an error when I compile the following code: #include <algorithm> #include <cctype> #include <iostream> #include <string> using namespace std; string&
11
by: TheDD | last post by:
Hello, i don't manage to use the tolower() function: #include <algorithm> #include <iostream> #include <locale> #include <string> using std::cout;
2
by: Daniel Aarno | last post by:
As far as I can tell the locale header should provide a tolower function however the following failes for me under gcc 3.4. transform(begin, end, begin2, std::tolower); with an error that the...
4
by: Eric Lilja | last post by:
Hello, consider this program: #include <iostream> #include <algorithm> #include <string> #include <cctype> int main() { std::string s = "HEJ";
5
by: Faray | last post by:
Hello, this is my first post, so hopefully I am posting this in the right place. Hopefully someone will be able to help me out with my problem here it is: I need to make a program that ask a...
6
by: tgnelson85 | last post by:
Hello, I've managed to get my c++ code calling my c code, and i can call a function that prints something to the screen etc. However, i am trying to call the following C function: char*...
13
by: Soumen | last post by:
I wanted convert a mixed case string to a lower case one. And I tried following code: std::transform(mixedCaseString.begin(), mixedCaseString::end(), mixedCaseString.begin(),...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...

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.