How do I lowercase a string in Python?

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

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

Watch a course Python - The Practical Guide

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. If you want to update the original string, you can assign the result of the lower() method back to the original variable:

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

This will also output hello world.