Python Istitle String Method

Pubblicato il: 29 settembre 2015
sul canale di: Code master
2,315
37

Be sure to like, share and comment to show your support for our tutorials.

=======================================
Channel - https://goo.gl/pnKLqE
Playlist For This Tutorial - https://goo.gl/EyZFti
Latest Video - https://goo.gl/atWRkF
Facebook -   / mastercodeonline  
Twitter - https://twitter.com/mastercodeonlin?l...
Website - http://mastercode.online
======================================
Python Istitle String Method
In this Python tutorial, we will look at the Python istitle string method. The istitle string method looks a string object and determines if the string object is a title. A title would be an uppercase character followed by a lowercase character and lowercase characters are followed by additional lowercase characters. If the string object is a title the Python will return True and if the string object is not a title it will return False.

Python Istitle String Method Syntax
'String Object'.istitle()

'String Object' - This is a string object that may or may not contain a title format.
.istitle() - The istitle string method checks if the string is in title format. If the string has an uppercase character followed by a lowercase character than Python will return True if not then Python returns False.
Examples Of The Python Istitle String Method
#Example 1
'Title'.istitle()
True

#Example 2
'title'.istitle()
False

#Example 3
'This Is A Title'.istitle()
True

#Example 4
'THIS IS NOT A TITLE'.istitle()
False

#Example 5
'NoR iS tHiS a Title'.istitle()
False
Examples Explained

Example 1:

'Title'.istitle()- In this example, we create a string object and then we call the istitle string method on our string object.

True - We are returned True because the first letter is an uppercase character followed by lowercase letters

Example 2:

'title'.istitle() - We create a string object that only contains lowercase letters and we call the istitle string method on our string object.

False- We are returned a False boolean since the first character in 'title' is not uppercase.
Example 3:

'This Is A Title'.istitle() - We create a string object with the proper title format and then call the istitle string method on our string object.

True - We are returned a True boolean since the string is in a proper title format. The uppercase letters are followed by lowercase letters.
Example 4:

'THIS IS NOT A TITLE'.istitle() - We create a new string object that contains all uppercase letters and then we call the istitle string method.

False - We are returned False since our string object only contains uppercase letters.
Example 5:

'NoR iS tHiS a Title'.istitle() - We create a string with alternating uppercase and lowercase letters and then we call our string method of istitle on our string object.

False - We are returned False since an uppercase letter can only be followed by lowercase letters.
Conclusion

In this Python tutorial we looked at the Python istitle string method which checks if a string object is in a title format. If you have any questions about the istitle string method leave a comment below.


In questa pagina del sito puoi guardare il video online Python Istitle String Method della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Code master 29 settembre 2015, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 2,315 volte e gli è piaciuto 37 spettatori. Buona visione!