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 Program to Calculate the Area of a Triangle
Python Dictionary clear()
Python Program to Check If a String Is a Number (Float)
Python Program to Get File Creation and Modification Date
Python frozenset()
Python oct()
Node.js vs Python for Backend Development
Python String count()
Python range()
Python String expandtabs()
Python Program to Delete an Element From a Dictionary
Python Program to Check if a Number is Odd or Even
Python bytes()
Jackson – Marshall String to JsonNode
Python String rjust()
JavaScript Eval: run a code string
Python filter()
Python Program to Remove Punctuations From a String
Python iter()
Python Program to Print all Prime Numbers in an Interval
Python sleep()
Python String casefold()
Python Program to Display Fibonacci Sequence Using Recursion
Python String isspace()
Python Program to Sort Words in Alphabetic Order
Python Program to Check the File Size
Adding a Newline Character to a String in Java
Python sorted()
Python Deep Learning Cookbook - Indra den Bakker
Python Program to Find the Sum of Natural Numbers
Python if...else Statement
Python Set intersection_update()