How to Convert a Python String to Lowercase?
To convert a Python string to lowercase, you can use the lower()
method.
Here's an example:
str1 = "HELLO WORLD"
str2 = str1.lower()
print(str2)
Output:
hello world
In this example, we create a string str1
in all uppercase. We then use the lower()
method to create a new string str2
that is the lowercase version of str1
. We then print out str2
to verify that it is lowercase.