To convert strings to all lowercase characters in Python, you can use the str.lower()
method. This method converts all uppercase characters in a string to their lowercase counterparts. Here’s an example:
string = "Hello World"
lowercase_string = string.lower()
print(lowercase_string)
Output:
hello world
In the code above, the lower()
method is applied to the string variable string
, which converts all uppercase characters in the string to lowercase. The resulting lowercase string is then printed.
It’s important to note that the str.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()
.
+ There are no comments
Add yours