AppDividend
Latest Code Tutorials

Python String isupper islower upper lower Functions Tutorial With Example

0

Python String isupper islower upper lower Functions Tutorial With Example is today’s topic. We will see four different methods of Python String handling which are isupper(), islower(), upper(), and lower(). These are the built-in method used for string handling.

Python String isupper islower upper lower

Python isupper() method returns “True” if all the characters in the string are uppercase; otherwise, It returns “False.”

Python islower() method returns “True” if all the characters in the string are lowercase; otherwise, it returns “False.”

Python upper() method returns the uppercased string from the given string. It converts all lowercase characters to the uppercase.

Python lower() method returns the lowercased string from the given string. It converts all uppercase characters to the lowercase.

Python String isupper() Method

The method isupper() checks whether all the case-based characters (letters) of the string are uppercase.

The syntax for isupper() method is following.

string.isupper()

See the following example.

# app.py

avengers = 'WE ARE IN THE ENDGAME NOW'
print(avengers.isupper())

The output is following.

Python String isupper islower upper lower Functions Tutorial With Example

 

Now, let’s check another string.

# app.py

eddie = 'We are Venom'
print(eddie.isupper())

The output is following.

Python String isupper() Method

 

The above string does not contain all the letters in uppercase; that is why it returns the false.

Python isupper() method returns “True” for whitespaces.

The isupper() method does not take any arguments; therefore, It returns an error if the parameter is passed.

The digits and symbols return “True,” only the uppercase letter returns “False.”

Python String islower() Method

The method islower() checks whether all the case-based characters (letters) of the string are lowercase.

The syntax for Python islower() method is following.

string.islower()

See the below example code.

# app.py

eddie = 'We are Venom'
print(eddie.islower())

The output is following.

Python String islower() Method

 

Above string does not contain all the letters in the lowercase that is why it returns False. See another example code below.

# app.py

tony = 'i am ironman'
print(tony.islower())

The output is following.

Python String islower() Example

 

Python islower() method returns “True” for whitespaces as well.

It does not take any arguments; therefore, It returns an error if the parameter is passed.

Digits and symbols return “True,” Only a lowercase letter returns “False.”

Python String upper() Method

Python String upper() method returns a copy of the string in which all case-based characters have been uppercased. It converts the string to the uppercase.

The syntax is following.

string.upper()

It does not take any argument. See the following example code.

# app.py

tony = 'i am ironman'
print(tony.upper())

The output is following.

Python String upper() Method

 

Python upper() method does not take any arguments; therefore, It returns an error if the parameter is passed.

Digits and symbols return as it is, Only a lowercase letter is returned after converting to uppercase.

Python String lower() Method

Python String lower() method returns a copy of the string in which all case-based characters have been lowercased. It converts the string into the lowercased string. See the following syntax.

string.lower()

See the below code example.

# app.py

avengers = 'WE ARE IN THE ENDGAME NOW'
print(avengers.lower())

The output is following.

Python String lower() Method Example

 

Python lower() method does not take any arguments; therefore, It returns an error if the parameter is passed.

Digits and symbols return returned as it is, Only an uppercase letter is returned after converting to lowercase.

Conclusively, Python String isupper islower upper lower Functions Tutorial With Example is over.

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.