lower(), upper() & title() – islower(), isupper() & istitle() function in python

Python has wide range of function for string handling. some ways of string handling are to convert a string to lowercase, uppercase and title case  using lower(), upper() & title() function respectively. The other ways of handling strings is to check whether the string is in lowercase using islower() function , whether the string is in uppercase  or title case using isupper()  and istitle() function.

  • lower() Function in python converts the input string to lowercase
  • upper() Function in python converts the input string to uppercase
  • title() Function in python converts the input string to proper case or title case. that is, all words begin with uppercase and the rest are lowercase.
  • islower() Function in python checks whether the input string is in lowercase
  • isupper() Function in python checks whether the input string is in uppercase
  • istitle() Function in python checks whether the input string is in title case

 

Syntax of lower() Function in python

str.lower()

Example of lower() Function in python

upper() lower() title() isupper() islower() and istitle() function in pandas 1

lower() Function in python converts the input string to lower case

''' convert text to lower case '''
str = "SALUTE to the Mother EARTH";
str.lower()

so the output will be in lowercase as shown below.

salute to the mother earth

 NOTE:

  1. lower() function does not take any arguments, Therefore, It returns an error if a parameter is passed.
  2. Digits and symbols are returned as it is, Only text string is converted to lowercase.

 

Syntax of upper() Function in python

str.upper()

Example of upper() Function in python

upper() lower() title() isupper() islower() and istitle() function in pandas 2

upper() Function in python converts the input string to upper case

''' convert text to upper case '''

str = "SALUTE to the Mother EARTH";
str.upper()

so the output will be in uppercase as shown below.

SALUTE TO THE MOTHER EARTH

Note:

  1. upper() function does not take any arguments, Therefore, It returns an error if a parameter is passed.
  2. Digits and symbols are returned as it is, Only text string is converted to uppercase.

 

 

Syntax of title() Function in python

str.title()

Example of title() Function in python

upper() lower() title() isupper() islower() and istitle() function in pandas 3

  • title() Function in python converts the input string to Proper case or title case. i.e. , all words begin with uppercase and the rest are lowercase.
''' convert text to proper case '''
str = "SALUTE to the Mother EARTH";
str.title()

so the output will be in proper case or title case as shown below.

Salute To The Mother Earth

 


islower(), isupper() & istitle() function in python

Syntax for isupper() Function in Python:

str.isupper()
1.True- If all characters in the string are upper.
2.False- If the string contains 1 or more non-uppercase characters.

Example of isupper() Function in python:

upper() lower() title() isupper() islower() and istitle() function in pandas 6

str1 = " 2018 IS AT DOORSTEP"; 
str1.isupper()

str1="Beauty of DEMOCRACY"
str1.isupper()

so the output will be

True
False

 

some more examples:  below are some more examples for isupper() function

>>> ”.isupper()
False
>>> ‘xyz123’.isupper()
False
>>> ‘xyz’.isupper()
False
>>> ‘123’.isupper()
False
>>> ‘Abc Def’.isupper()
False
>>> ‘fgh ijk’.isupper()
False
>>> ‘%$!@#’.isupper()
False
>>> ‘ ‘.isupper()
False
>>> ‘ABC’.isupper()
True

 

 

Syntax for islower() Function in Python:

str.islower()
1.True- If all characters in the string are lower.
2.False- If the string contains 1 or more non-lowercase characters.

Example of islower() Function in python:

upper() lower() title() isupper() islower() and istitle() function in pandas 4

str1 = "2018 is at doorstep"; 
str1.islower() 

str1="Beauty of DEMOCRACY" 
str1.islower()

so the output will be

True
False

 

some more examples:  below are some more examples for islower() function

>>> ”.islower()
False
>>> ‘xyz123’.islower()
True
>>> ‘xyz’.islower()
True
>>> ‘123’.islower()
False
>>> ‘Abc Def’.islower()
False
>>> ‘fgh ijk’.islower()
True
>>> ‘%$!@#’.islower()
False
>>> ‘ ‘.islower()
False
>>> ‘ABC’.islower()
False

 

Syntax for istitle() Function in Python:

str.istitle()
1.True- If all words in the string are starting with uppercase.
2.False- If 1 or more words of the string starts with non-uppercase.

Example of istitle() Function in python:

upper() lower() title() isupper() islower() and istitle() function in pandas 7

str1 = " 2018 IS AT DOORSTEP"; 
str1.istitle()

str1="Beauty Of Democracy"
str1.istitle()

so the output will be

False
True

 

For further understanding of lower(), upper() & title() – islower(), isupper() & istitle() function in python one can refer the documentation


Other Related Topics

 

previous lower() upper() & title() function in python                                                                                                           next lower() upper() & title() function in python

Author

  • Sridhar Venkatachalam

    With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.