W3docs

How do I lowercase a string in Python?

You can use the lower() method to lowercase a string in Python.

You can use the lower() method to lowercase a string in Python. Here is an example:

Lowercase a string in Python

string = "HELLO WORLD"
lowercase_string = string.lower()
print(lowercase_string)

<div class="alert alert-info flex not-prose"> Watch a course <span class="hidden md:block">Watch a video course </span> Python - The Practical Guide</div>

This will output hello world. Note that the lower() method does not modify the original string; it returns a new string with all the characters in lowercase. The following example demonstrates that the original string remains unchanged:

Lowercase a string in Python and printing the original string which remains unchanged

string1 = "HELLO WORLD"
string2 = string1.lower()
print(string1)

This will output HELLO WORLD.