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

big letter -> small letter

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

Jul 18 '05 #1
4 3846
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
Jul 18 '05 #2
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
Jul 18 '05 #3
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
Jul 18 '05 #4
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
Jul 18 '05 #5

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

Similar topics

6
by: Yannick | last post by:
Hey everybody, Do you know if ASP can change a JPG file in a smaller defined size JPG. Do you have an exemple of it. Imagine the JPG is on the C: drive of my server and called PIC.JPG. Thanks...
6
by: Paul Gorodyansky | last post by:
Hi, Question about event.altKey event.ctrlKey event.shiftKey If I need to catch when a user does say Ctrl+Alt+G - somehow event.altKey is not working, i.e.:
28
by: dingbat | last post by:
I'm writing a "tabbed folder" nav bar. Site standards are graphical prettiness, CSS throughout, valid code, but accesibility is ignored where it conflicts with prettiness. The particular issue...
1
by: kids_pro | last post by:
Hi there, I want to capture the last key press in a textBox. So I decided to use KeyDown event and from the KeyEventArgs I read the e.KeyCode But when I type small letter the e.KeyCode always...
2
by: trint | last post by:
I need to know if this string, which will always vary is a letter or a number value AND if it is a letter, to only get the number, which is obviously 7000: string prodID = "us7000"; is Parse,...
17
by: cpptutor2000 | last post by:
Could some C guru please help me? I have a simple piece of code as: #include <stdio.h> #include <stdlib.h> #include <openssl/rand.h> int main(){ unsigned char temp; RAND_bytes(temp, 4);
17
by: Cralis | last post by:
I am trying to populate a ListView with a list of 'Models' of cars. I have a data object class for my models, which has a function, 'getListOfModels', which I want to retuyrn a <Listof models. ...
11
by: Gerald I. Evenden | last post by:
Working on a Kubuntu 64bit system "c++ (GCC) 4.0.3". The following simple program extracted from p.497 & 499 of N.M.Josurris' "The C++ Standard Library ... " (file t.cpp): 1 #include <string>...
13
by: umpsumps | last post by:
Hello, Here is my code for a letter frequency counter. It seems bloated to me and any suggestions of what would be a better way (keep in my mind I'm a beginner) would be greatly appreciated.. ...
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.