Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Is there any way to convert an entire user inputed string from uppercase, or even part uppercase to lowercase? eg. Kilometers --> kilometers. I am writing a program that doesn't work when any sort of uppercase word is inputed and it would take LOTS more lines of code to make it work with uppercase. (I'm kind of new to programming so this may seem like a stupid question). THANKS

share|improve this question
1  
If you use an IDE such as Pycharm, you can learn the methods and functions of languages faster with autocomplete. Python is great, too, because the methods are all logically named, so you can guess and usually you're right. –  notbad.jpeg May 4 at 18:02

4 Answers 4

up vote 530 down vote accepted
s = "Kilometer"
print(s.lower())

Official documentation here

share|improve this answer
5  
Python docs: docs.python.org/3.3/library/… –  The Demz Oct 21 '13 at 11:22

You can do what Peter said, or if you want the user to input something you could do this:

raw_input('Type Something').lower()

It will then automatically convert the thing they typed into lowercase. :)

Note: raw_input was renamed to input in Python 3.x and above.

share|improve this answer

also, you can overwrite some variables:

s = input('UPPER CASE')
lower = s.lower()

if you use like this:

s = "Kilometer"
print(s.lower())     - kilometer
print(s)             - Kilometer

it will work just when call.

share|improve this answer

This doesn't work for non-english words in utf-8. In this case decode('utf-8') can help.

>>> s='Километр'
>>> print s.lower()
Километр
>>> print s.decode('utf-8').lower()
километр
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.