69

I have a script which reads the input and than lists it, however i want it to convert upper case letters to lower case, how can i do that?

this is what i got

 for words in text.readlines():
    sentence = [w.strip(',.') for w in line.split() if w.strip(',.')]
    list.append(sentence)
user998316
  • 10,313
  • 4
  • 18
  • 11
  • 5
    if you found the `strip` and `split` methods of `str`, how hard can it be to search for `upper` and `lower`? – JBernardo Oct 22 '11 at 19:24
  • 5
    please type these things into google before coming here, python docs is hit 1 and has the correct answer. For the record the answer is `thestring.lower()` – Serdalis Oct 22 '11 at 19:25

3 Answers3

133

You can find more methods and functions related to Python strings in section 5.6.1. String Methods of the documentation.

w.strip(',.').lower()
Ehtesh Choudhury
  • 7,452
  • 5
  • 42
  • 48
29

str.lower() converts all cased characters to lowercase.

Dennis
  • 14,264
  • 2
  • 48
  • 57
5

To convert a string to lower case in Python, use something like this.

list.append(sentence.lower())

I found this in the first result after searching for "python upper to lower case".

orangething
  • 708
  • 5
  • 16