Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > big letter -> small letter

Reply
Thread Tools

big letter -> small letter

 
 
vertigo
Guest
Posts: n/a
 
      07-06-2004
Hello
How can i change big letter to small letter ?

When i tried char=char+32 i received error that can not add int to sring.

Thanx
Michal

 
Reply With Quote
 
 
 
 
Reinhold Birkenfeld
Guest
Posts: n/a
 
      07-06-2004
vertigo wrote:
> Hello
> How can i change big letter to small letter ?
>
> When i tried char=char+32 i received error that can not add int to sring.


That's C thinking, you have to get away from that

In Python, there is no "char" type. Every char is a string, and you
can't add an integer to a string.

But, luckily, everything is an object, too, and has useful methods to do
something with the object. In case of your problem, that would be

char = char.lower()

Reinhold

--
Wenn eine Linuxdistribution so wenig brauchbare Software wie Windows
mitbrächte, wäre das bedauerlich. Was bei Windows der Umfang eines
"kompletten Betriebssystems" ist, nennt man bei Linux eine Rescuedisk.
-- David Kastrup in de.comp.os.unix.linux.misc
 
Reply With Quote
 
 
 
 
Irmen de Jong
Guest
Posts: n/a
 
      07-06-2004
vertigo wrote:
> Hello
> How can i change big letter to small letter ?
>
> When i tried char=char+32 i received error that can not add int to sring.


Which is ofcourse, correct behavior. You cannot add numbers to strings.

Use the tolower string method. It even works on strings of length >1:

>>> print "BiGLeTtEr".lower()

bigletter

There's also an upper().

--Irmen
 
Reply With Quote
 
Bernd Kaiser
Guest
Posts: n/a
 
      07-06-2004
vertigo wrote:
> Hello
> How can i change big letter to small letter ?
>
> When i tried char=char+32 i received error that can not add int to sring.
>
> Thanx
> Michal
>

Check out the String Modul
http://python.org/doc/2.3.4/lib/module-string.html

Redards,
Bernd
 
Reply With Quote
 
Reinhold Birkenfeld
Guest
Posts: n/a
 
      07-06-2004
Bernd Kaiser wrote:
> vertigo wrote:
>> Hello
>> How can i change big letter to small letter ?
>>
>> When i tried char=char+32 i received error that can not add int to sring.
>>
>> Thanx
>> Michal
>>

> Check out the String Modul
> http://python.org/doc/2.3.4/lib/module-string.html


Caution! Always use the functions of the str object itself, not the
correspondig method of the string module because the former is quicker.
There are cases where you need the string module, but they have become rare.

Instead of "string.upper(s)" use "s.upper()"

Reinhold

--
Wenn eine Linuxdistribution so wenig brauchbare Software wie Windows
mitbrächte, wäre das bedauerlich. Was bei Windows der Umfang eines
"kompletten Betriebssystems" ist, nennt man bei Linux eine Rescuedisk.
-- David Kastrup in de.comp.os.unix.linux.misc
 
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
GIDS 2009 .Net:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf ASP .Net 0 12-26-2008 09:29 AM
GIDS 2009 .Net:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf ASP .Net Web Controls 0 12-26-2008 06:11 AM
GIDS 2009 Java:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf Python 0 12-24-2008 07:35 AM
Re: big letter -> small letter Andrew McNamara Python 2 07-06-2004 02:09 PM
RE: big letter -> small letter Tony Meyer Python 0 07-06-2004 07:11 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57