How to Convert Strings to All Lowercase in Python?

Estimated read time 1 min read

To convert strings to all lowercase in Python, you can use the lower() method. Here’s an example:

string = "Hello World"
lowercase_string = string.lower()
print(lowercase_string)

Output:

hello world

In the above code, the lower() method is applied to the string variable string. This method returns a new string with all characters converted to lowercase. The resulting lowercase string is then printed.

Note that the lower() method does not modify the original string. Instead, it returns a new string with the lowercase conversion. If you want to update the original string variable, you can assign the result back to it like this: string = string.lower().

You May Also Like

More From Author

+ There are no comments

Add yours

Leave a Reply