filmov
tv
Python Isalpha String Method
![preview_player](https://i.ytimg.com/vi/NRvBpWnMXzo/maxresdefault.jpg)
Показать описание
Be sure to like, share and comment to show your support for our tutorials.
=======================================
======================================
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'
True
Example 4:
b = 'Python3'
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.
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.
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.
=======================================
======================================
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'
True
Example 4:
b = 'Python3'
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.
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.
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.
Комментарии