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 Isalpha String Method
In this tutorial we will explore the Python isalpha string method. The isalpha string method gives us the ability to check a string object to see if it consists of just alphabetic characters. If the string object contains letters A thru Z then Python will return True and if the string object contains any other character or symbol we will be returned a boolean of False. So if your string contains a space it will return False.
Python Isalpha String Method Syntax
'String'.isalpha()
'String' - If this string object contains just alphabetic characters we will be returned True and this string object contains anything other than alphabetic character then we are returned a False boolean.
Examples of the Python Isalpha String Method
Example 1:
'abcdef'.isalpha()
True
Example 2:
'This is a string'.isalpha()
False
Example 3:
a = 'Python'
a.isalpha()
True
Example 4:
b = 'Python3'
b.isalpha()
False
Examples Explained
Example 1:
'abcdef'.isalpha()- In this example, we create a string object that contains only alphabetic characters and then we call the isalpha string method on our string object.
True- We are returned True because our string object only contains alphabetic characters and no other numbers or symbols.
Example 2:
'This is a string'.isalpha()- In this example, we create a string object that contains alphabetic characters and spaces then we call the isalpha string method on our string object.
False- We are returned False because object contains spaces.
Example 3:
a = 'Python'- In this example, we create a string object that contains all alphabetic characters and assign 'a' variable to represent the string object.
a.isalpha()- We call our string object via the variable 'a' and then call the isalpha string method on our string object.
True- We are returned True since our string object only contains alphabetic characters.
Example 4:
b = 'Python3'- In this example, we create a string object that contains alphabetic and numeric characters and then we assign 'b' to represent the string object.
b.isalpha()- We call our string object via the variable 'b' and then call the isalpha string method on our string object.
False - We are returned False because our string object contains a number.
Conclusion
In this tutorial we looked at the Python isalpha string method and if you have any questions about this string method leave a comment below.
In questa pagina del sito puoi guardare il video online Python Isalpha String Method della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Code master 25 settembre 2015, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 10,307 volte e gli è piaciuto 99 spettatori. Buona visione!