Table of Contents
In this tutorial, we will learn about the Python String upper() method with the help of examples.
The lower() method converts all uppercase characters in a string into lowercase characters and returns it.
Example
message = 'PYTHON IS FUN' # convert message to lowercase print(message.lower()) # Output: python is fun
1. Syntax of String lower()
The syntax of lower() method is:
string.lower()
2. lower() Parameters()
lower() method doesn’t take any parameters.
3. lower() Return value
lower() method returns the lowercase string from the given string. It converts all uppercase characters to lowercase.
If no uppercase characters exist, it returns the original string.
4. Example 1: Convert a string to lowercase
# example string string = "THIS SHOULD BE LOWERCASE!" print(string.lower()) # string with numbers # all alphabets should be lowercase string = "Th!s Sh0uLd B3 L0w3rCas3!" print(string.lower())
Output
this should be lowercase! th!s sh0uld b3 l0w3rcas3!
5. Example 2: How lower() is used in a program?
# first string
firstString = "PYTHON IS AWESOME!"
# second string
secondString = "PyThOn Is AwEsOmE!"
if(firstString.lower() == secondString.lower()):
print("The strings are same.")
else:
print("The strings are not same.")
Output
The strings are same.
Note: If you want to convert to uppercase string, use upper(). You can also use swapcase() to swap between lowercase to uppercase.
Related posts:
Python list()
Python String istitle()
Check If a String Is Numeric in Java
Python frozenset()
Building Chatbots with Python Using Natural Language Processing and Machine Learning - Sumit Raj
Python String count()
Python ord()
Python Program to Solve Quadratic Equation
Most commonly used String methods in Java
Python eval()
Python ascii()
Python String casefold()
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...
Python Program to Get the Full Path of the Current Working Directory
Python len()
Python Program to Sort Words in Alphabetic Order
Python Set issuperset()
Python Exception Handling Using try, except and finally statement
Python id()
Python List index()
Python Program to Find the Largest Among Three Numbers
Python Program to Copy a File
Python Shallow Copy and Deep Copy
Python Dictionary pop()
Python Program to Count the Occurrence of an Item in a List
Python List pop()
Java Program to Permute All Letters of an Input String
Python Dictionary clear()
Python Deep Learning - Valentino Zocca & Gianmario Spacagna & Daniel Slater & Peter Roelants
Python str()
Python List count()
Python Program to Extract Extension From the File Name