How do I lowercase a string in Python?

Benjamin Didur picture Benjamin Didur · Jul 23, 2011 · Viewed 2.5M times · Source

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

For example, "Kilometers" → "kilometers".

Answer

Petar Ivanov picture Petar Ivanov · Jul 23, 2011

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()