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:
Convert String to Byte Array and Reverse in Java
Python Program to Represent enum
Python Set pop()
Python String expandtabs()
Converting a Stack Trace to a String in Java
Python str()
Generate a String
Python min()
Python Program to Access Index of a List Using for Loop
Python Program to Find the Factors of a Number
Python del Statement
Python Program to Count the Number of Digits Present In a Number
Python complex()
Python Program to Find LCM
Converting a List to String in Java
Deep Learning with Python - Francois Cholletf
Python Program to Transpose a Matrix
Python Set union()
Introduction to Machine Learning with Python - Andreas C.Muller & Sarah Guido
Python strftime()
Python enumerate()
Python List reverse()
Python Program to Solve Quadratic Equation
Building Machine Learning Systems with Python - Willi Richert & Luis Pedro Coelho
Python Inheritance
Python __import__()
Java InputStream to String
Python Program to Check If a List is Empty
Natural Language Processing with Python - Steven Bird & Ewan Klein & Edward Loper
Python locals()
Jackson – Marshall String to JsonNode
Python String isdigit()