Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




istitle( ) FUNCTION


istitle( ) Function


The istitle( ) Function is used to check if all the words in the String starts with an uppercase letter.


Example :


x = "Hello Beautiful World"
if x.istitle():
    print("The words in the String are in title format")
else:
    print("No! Not all the words in the String are in title format")


Output :



  The words in the String are in title format

In the above code, we have declared a String 'Hello Beautiful World' that has all words with the first letter in uppercase.


x = "Hello Beautiful World"

java_Collections

So, to check, if all the words in the String has the first letter in uppercase, we have used 'istitle( )' function.


if x.istitle():
    print("The words in the String are in title format")
else:
    print("No! Not all the words in the String are in title format")

And in this case, the words in the String are in title format. So, we got the below output.


The words in the String are in title format

Similarly, let us look at the next example.


Example :


x = "Hello beautiful World"
if x.istitle():
    print("The words in the String are in title format")
else:
    print("No! Not all the words in the String are in title format")


Output :



  No! Not all the words in the String are in title format

In the above code, we have declared a String 'Hello beautiful World' that has the word 'beautiful' that has its first letter in uppercase.


x = "Hello beautiful World"

java_Collections

So, to check, if all the words in the String has the first letter in uppercase, we have used 'istitle( )' function.


if x.istitle():
    print("The words in the String are in title format")
else:
    print("No! Not all the words in the String are in title format")

And in this case, the word 'beautiful' is not in the title format. So, we got the below output.


No! Not all the words in the String are in title format