The lower() function in Python converts a string to print out a string consisting of all lowercase characters. The upper() function in Python converts a string to print out a string consisting of all uppercase characters. These are useful functions to transform strings.
Here at LinuxAPT, you will learn about how to use the lower() and upper() functions in Python.
1. The lower() function
This converts a string with all lowercase.
2. The upper() function
This converts a string with all uppercase.
1. The lower() function
string.lower()
2. The upper() function
string.upper()
Parameter Values:
No parameter.
1. The lower() function:
str = "HEllo"
x = str.lower()
print(x)
The Output will give:
hello
2. The upper() function:
str = "HEllo"
x = str.upper()
print(x)
The Output will give:
HELLO
3. Converting a string to lowercase:
print("Enter the string you want to convert:")
x = input().lower()
print("The converted string is:",x)
The Output will give:
Enter the string you want to convert: HeLLo
The converted string is: hello
4. Converting a string to uppercase:
print("Enter the string you want to convert:")
x = input().upper()
print("The converted string is:",x)
The Output will give:
Enter the string you want to convert: hello
The converted string is: HELLO
This article covers how to use the lower() and upper() functions in Python. In fact, the upper() method converts all lowercase characters in a string into uppercase characters and returns it while the lower() method converts all uppercase characters in a string into lowercase characters and returns it.