The istitle( ) Function is used to check if all the words in the String starts with an uppercase letter.
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")
In the above code, we have declared a String 'Hello Beautiful World' that has all words with the first letter in uppercase.
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.
Similarly, let us look at the next 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")
In the above code, we have declared a String 'Hello beautiful World' that has the word 'beautiful' that has its first letter in uppercase.
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.