Python Lowercase: A Step-By-Step Guide

Table of Contents Python LowercaseWhy do we need python lowercase () function?Syntax of python lowercase function:Python list in lowercasePython islower()Conclusion: Python Lowercase Python lowercase is a built-in function in python that converts the string or …

Python Lowercase

Python Lowercase

Python lowercase is a built-in function in python that converts the string or alphabetic character into lower-case.

Python lowercase method only converts the strings, alphabetic characters, letters into lowercase. It does not make any difference to numerical values and symbols.

Why do we need python lowercase () function?

As python is a case-sensitive language and specifying any uppercase letter can cause an error, if we use the lowercase () function or method, then we can avoid the risk of error.

Syntax of python lowercase function:

After string .lower() function will convert the string into lower case.

The lower () function does not take any parameters or conditions, or ranges inside it.

Let’s check its examples to know it better.

Example1:

#example string
string = "ANYTHING CAN BE CONVERTED INTO LOWERCASE!"
print(string.lower())

# string with numbers
# all alphabets should be lowercase
string = "ANYTHING CAN B3 CO9VERT3D IN2 L0w3rCas3!"
print(string.lower())

Output:

anything can be converted into lowercase!
anything can b3 co9vert3d in2 l0w3rcas3!
> 

In the above example,

First, we defined the string and then, inside the print function, used the syntax of python lowercase to convert the string into lowercase.

Then, we took another string with numbers to convert it into lowercase again used the python lowercase function inside the print function.

Example2:

 #first string
firstString = "ANYTHING CAN BE CONVERTED INTO LOWERCASE!"

# second string
secondString = "anything can Be cOnveRted into LoweRcaSe!"

if(firstString.lower() == secondString.lower()):
    print("The strings are same.")
else:
    print("The strings are not same.")

Output:

The strings are same.
> 

In above example2, we defined two strings and compared them using if-else conditions, and within the if condition, we applied the python lowercase method.

Python list in lowercase

A list is used to merge many different items or elements into one variable. 

In python, we create a list of strings in which different elements are stored in a single variable.

Python list in lowercase is used to make the uppercase string list into lowercase.

Let’s take an example to understand it:

Example:

#python lowercase
#python list in lowercase
#list of strings

s = ["aNYtHiNG","EVERYThING","sOMETHINg"]

#using for-loop method
for i in range(len(s)):
    s[i] = s[i].lower()
print(s)

Output:

['anything', 'everything', 'something']

In the above example, we converted the python list of strings to lowercase, by using the for loop method, and inside the for loop, we defined the syntax of python lowercase to convert the list items into lowercase .

Python islower()

Python islower() function is used to check-in python if the string is in uppercase or lowercase, and it will return a boolean value as output.

If all the string characters are in lowercase, then it will return True. Otherwise, it will return False.

Syntax:

string.islower()

Python islower() function also does not take any parameters in it like the python lowercase method.

Let’s take an example to understand it better:

Example:

#python lowercase
#python islower

s = 'anything can be converted into lowercase'
print(s.islower())

s = 'Anthing can be converted into lowercase'
print(s.islower())

s = 'ANYTHING CAN BE CONVERTED INTO LOWERCASE'
print(s.islower())

Output:

True
False
False

In the above example, we defined three strings to check how the python islower function responds to them and observed that if a string contains a single uppercase character, it will return false, when all the characters of a string are in lowercase, then it will return True.

Conclusion:

In this article, we defined the python’s built-in function “Python Lowercase, Python list in lowercase(), and python islower() method along with their syntax, details, and solved examples with explanations.

Suggested Read: Remove Brackets from list Python

Leave a Comment