How Can We Help?
In this tutorial, we will explain how to use Python string lower() method with basic syntax by example for better understanding.
How to make string lowercase in Python? To make a sting lowercase in Python, we use the lower() method. The lower method in Python converts all characters of a string to be in lowercase. It returns a copy of the original string.
Syntax:
<string_value/string_variable>.lower()
Input Parameters:
- string_value / String variable : The string that we want to convert it to lowercase.
String Lowercase All Characters
Example (1)
msg= 'Welcome to PYTHON'
print('Lowercase: ',msg.lower())
Output of example (1)
Lowercase: welcome to python
In the above example, in the value of string variable ‘msg’; ‘W’ and ‘PYTHON’ are uppercase. Using msg.lower() in the print statement, we have converted them into lowercase.
Python String Lowercase First Letter
Example (2)
msg = "LearnPythonWithOraask"
# Using lower() + string slicing
# Lowercase the first character of a String
result = msg[0].lower() + msg[1:]
# printing result
print("Lowercase the initial character : " + result)
Output of example (2)
Lowercase the initial character : learnPythonWithOraask
In the above example, in the string variable’s value, the first character of the letter is in uppercase, and by using msg[0].lower() along with string slicing, we have converted the first character whose index is 0 to lowercase.
In this tutorial, you have learned the string lower() method in Python. What is it? And how to convert all character of given string to lowercase.
Hopefully, it was clear and concise.
If you have an inquiry or doubt, don’t hesitate to leave them in a comment. We are waiting for your valuable feedback.
Similar Python String Formatting Methods:
- title() : It returns the “title cased” version of string means all the words start with uppercase and the remaining are lowercase.
- capitalize() : It capitalizes the first character of the String.
- center() : It returns a space-padded string with the original string centered to a total of width columns.
- swapcase() : It inverts the case of all the characters in a string.
- upper() : It converts all the characters of a string to uppercase.
- rstrip() : It removes particular character of a string from right side.
- lstrip() : It removes particular character of a string from left side.
- strip(chars) : It removes particular characters of a string from left and right side.
- ljust() : It returns an original string with a filled specific character or space at the left side of the string value to justify the string’s new length (width).
- rjust() : It returns an original string with a filled specific character or space at the right side of the string value to justify the string’s new length (width).
- zfill() : It returns an original string value with filled zero at the left side of the string value to justify the string’s new length (width).
Related Articles
Python String – Mastering By Practical Examples (Comprehensive Guide)
Python Tutorials List:
- Python tutorials list : access all python tutorials.