The lower() method in Python
In this example, we have stored a string in variable ‘string1’ which includes uppercase letters, and converted it to lowercase using the lower() method after that we printed that converted string.
Python3
# Define a string string1 = "w3wiki" print (string1) # Store the output of lower() method # in string2 string2 = string1.lower() print (string2) |
Output:
w3wiki w3wiki
Difference between casefold() and lower() in Python
In this article, we will learn the differences between casefold() and lower() in Python. The string lower() is an in-built method in Python language. It converts all uppercase letters in a string into lowercase and then returns the string. Whereas casefold() method is an advanced version of lower() method, it converts the uppercase letter to lowercase including some special characters which are not specified in the ASCII table for example ‘ß’ which is a German letter and its lowercase letter is ‘ss’.
Syntax of lower(): string.lower() Parameters: It does not take any parameter. Returns: It returns a lowercase string of the given string. Syntax of casefold(): string.casefold() Parameters: It does not take any parameter. Returns: It returns a lowercase string of the given string.