How to convert upper case letters to lower case

Python

Python Problem Overview


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)

Python Solutions


Solution 1 - Python

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

w.strip(',.').lower()

Solution 2 - Python

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

Solution 3 - Python

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".

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser998316View Question on Stackoverflow
Solution 1 - PythonEhtesh ChoudhuryView Answer on Stackoverflow
Solution 2 - PythonDennisView Answer on Stackoverflow
Solution 3 - PythonorangethingView Answer on Stackoverflow