This website collects cookies to deliver better user experience
Python String isalpha()
Python String isalpha()
ItsMyCode |
Python string isalpha() method is mainly used to check if the string is the alphabet or not. The isalpha() method returns true if all the characters in the string are alphabets. Otherwise, it returns false.
Python String isalpha()
Syntax – string.isalpha()
*Parameters – * None
*Return Value – * Returns True if all the characters in the string are alphabets; otherwise, it returns false.
Example 2 – A practical example of the isalpha() method to check if the entered username is a valid alphabet or not.
username =input("Choose a username:")if username.isalnum()==True:print("The entered username is ", username)else:print("Please enter a valid usernameSrin.")
Output
Choose a username:ItsMycode
The entered username is ItsMycode