Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I lowercase a string in Python?

Is there a way to convert a string from uppercase, or even part uppercase to lowercase?

For example, "Kilometers" → "kilometers".

like image 437
Benjamin Didur Avatar asked Jul 23 '11 03:07

Benjamin Didur


People also ask

How do you turn a string into a lowercase?

The toLowerCase() method converts a string to lowercase letters. The toLowerCase() method does not change the original string.

How do I lowercase a word in Python?

. lower() is a built-in Python method primarily used for string handling. The . lower() method takes no arguments and returns the lowercased strings from the given string by converting each uppercase character to lowercase.

What does lower () mean in Python?

The lower() method returns a string where all characters are lower case. Symbols and Numbers are ignored.


1 Answers

Use .lower() - For example:

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

The official 2.x documentation is here: str.lower()
The official 3.x documentation is here: str.lower()

like image 131
Petar Ivanov Avatar answered Nov 07 '22 23:11

Petar Ivanov