isalpha()

Text Box

>>> 
>>> "Python Lake phone number: 571 402 2882".isalpha()
False
>>> 

Space among string characters returns false

>>> 
>>> "python".isalpha()
True
>>> 
>>> "Python Lake".isalpha()
False
>>> 

Using isalpha() with input()

x=input("Please enter your name: ")
if x != x.isalpha():
    print("Name can't contain number")
    

>>> 
Please enter your name: adil22
Name can't contain number
>>> 

str.isalpha()

Return with true or false value whether the string contain any number or not.

Comments