How to Convert a Python String to Lowercase?

python

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.

Latest Questions

python How to Fix ""zsh: command not found: python" Error on MacOS X? python How to Fix "xlrd.biffh.XLRDError: Excel xlsx file; not supported" Error in Pandas? python How to Remove All Whitespace From a Python String?