{"id":24466,"date":"2021-10-17T18:42:27","date_gmt":"2021-10-17T13:12:27","guid":{"rendered":"https:\/\/python-programs.com\/?p=24466"},"modified":"2021-11-05T19:24:18","modified_gmt":"2021-11-05T13:54:18","slug":"program-for-python-string-isalpha-method","status":"publish","type":"post","link":"https:\/\/python-programs.com\/program-for-python-string-isalpha-method\/","title":{"rendered":"Program for Python String isalpha() Method"},"content":{"rendered":"
In the previous article, we have discussed Python Program for isalnum() Function<\/a> If all of the characters are alphabet letters, the isalpha() method returns True (a-z).<\/p>\n (space)!#%&? etc are examples of characters that are not alphabets.<\/p>\n Syntax:<\/strong><\/p>\n Parameters: <\/strong>This function has no parameters.<\/p>\n Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Go through our tutorial and learn about various Python String Method Examples<\/a> and learn how to apply the knowledge while dealing with strings.<\/p>\n In the previous article, we have discussed Python Program for isalnum() Function isalpha() Function in Python: If all of the characters are alphabet letters, the isalpha() method returns True (a-z). (space)!#%&? etc are examples of characters that are not alphabets. Syntax: string.isalpha() Parameters: This function has no parameters. Examples: Example1: Input: Given first string = …<\/p>\n
\nisalpha() Function in Python:<\/strong><\/p>\nstring.isalpha()<\/pre>\n
Given first string = \"pythonprograms\"\r\nGiven second string = \"123456good morning\"<\/pre>\n
The above given first string is : pythonprograms\r\nThe given first string after applying isalpha() function: True\r\nThe above given second string is : 123456good morning\r\nThe given second string after applying isalpha() function: False<\/pre>\n
Given first string = \"hello123this is python programming platform\"\r\nGiven second string = \"hellogoodmorning\"<\/pre>\n
The above given first string is : hello123this is python programming platform\r\nThe given first string after applying isalpha() function: False\r\nThe above given second string is : hellogoodmorning\r\nThe given second string after applying isalpha() function: True<\/pre>\n
Program for isalpha() Function in Python<\/h2>\n
\n
Method #1: Using Built-in Functions (Static Input)<\/h3>\n
\n
# Give the first string as static input and store it in a variable.\r\ngvn_fststr = \"hello123this is python programming platform\"\r\n# Apply isalpha() function to the given first string that returns true if\r\n# all of the characters are alphabet letters.\r\n# Store it in another variable.\r\nrslt_str1 = gvn_fststr.isalpha()\r\n# Print the above given String\r\nprint(\"The above given first string is :\", gvn_fststr)\r\n# Print the above given String after applying isalnum() function.\r\nprint(\"The given first string after applying isalpha() function:\", rslt_str1)\r\n# Similarly do the same for other string and print the result string.\r\ngvn_scndstr = \"hellogoodmorning\"\r\nrslt_str2 = gvn_scndstr.isalpha()\r\nprint(\"The above given second string is :\", gvn_scndstr)\r\nprint(\"The given second string after applying isalpha() function:\", rslt_str2)\r\n<\/pre>\n
The above given first string is : hello123this is python programming platform\r\nThe given first string after applying isalpha() function: False\r\nThe above given second string is : hellogoodmorning\r\nThe given second string after applying isalpha() function: True<\/pre>\n
Method #2: Using Built-in Functions (User Input)<\/h3>\n
\n
# Give the first string as user input using the input() function and store it in a variable.\r\ngvn_fststr = input(\"Enter some Random String = \")\r\n# Apply isalpha() function to the given first string that returns true if\r\n# all of the characters are alphabet letters.\r\n# Store it in another variable.\r\nrslt_str1 = gvn_fststr.isalpha()\r\n# Print the above given String\r\nprint(\"The above given first string is :\", gvn_fststr)\r\n# Print the above given String after applying isalnum() function.\r\nprint(\"The given first string after applying isalpha() function:\", rslt_str1)\r\n# Similarly do the same for other string and print the result string.\r\ngvn_scndstr = input(\"Enter some Random String = \")\r\nrslt_str2 = gvn_scndstr.isalpha()\r\nprint(\"The above given second string is :\", gvn_scndstr)\r\nprint(\"The given second string after applying isalpha() function:\", rslt_str2)\r\n<\/pre>\n
Enter some Random String = pythonprograms\r\nThe above given first string is : pythonprograms\r\nThe given first string after applying isalpha() function: True\r\nEnter some Random String = 123456good morning\r\nThe above given second string is : 123456good morning\r\nThe given second string after applying isalpha() function: False<\/pre>\n
\n