Python - Lowercase String with str.lower()

1 min read

To convert all characters in a string to lowercase in Python you can use the string's lower() method.

capital = 'Colombo is the capital city of Sri Lanka'
lower = capital.lower()

print(lower)
# colombo is the capital city of sri lanka

You don't always have to assign the result of each step to a variable. Below are some more concise ways of using a string's lower() method.

capital = 'Bogotá is the capital city of Colombia'
print(capital.lower())
# bogotá is the capital city of colombia

print('Hanoi is the capital city of Vietnam'.lower())
# hanoi is the capital city of vietnam


Author picture
Rhett Trickett

Founder at Able

@rhett RhettTrickett rhetttrickett
Python

Join the discussion

Able is a developer community where people build their coding knowledge and careers.

Join with GitHub Join with Twitter