{"id":1926,"date":"2019-12-30T17:30:28","date_gmt":"2019-12-30T17:30:28","guid":{"rendered":"https:\/\/www.askpython.com\/?p=1926"},"modified":"2022-08-06T13:09:17","modified_gmt":"2022-08-06T13:09:17","slug":"python-string-isalpha-function","status":"publish","type":"post","link":"https:\/\/www.askpython.com\/python\/string\/python-string-isalpha-function","title":{"rendered":"Python String isalpha() Function"},"content":{"rendered":"\n<p>String in Python has built-in functions for almost every action to be performed on a string. Python String isalpha() function checks for the alphabets in a string and returns True if the string consists of only alphabets (a-z, A-Z).<\/p>\n\n\n\n<p><strong>Key Points :<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Return Type:<\/strong> Boolean i.e. True or False<\/li><li><strong>Parametric Values:<\/strong> No Parameters required<\/li><li>Blank Spaces are not considered as alphabets. Hence, blank spaces will return False.<\/li><li>Empty String also returns False.<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">String isalpha() Syntax<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nstr_name.isalpha()\n<\/pre><\/div>\n\n\n<p> str_name here refers to the input string. And, isalpha() is inbuilt string function in python. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nstr_name = &quot;Welcome&quot;\nprint(str_name.isalpha())   # True\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">String isalpha() Examples<\/h2>\n\n\n\n<p>Different cases are given below.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Case 1: String contains whitespace<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nstr_name = &quot;Welcome User&quot;\nprint(str_name.isalpha())   # False\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">Case 2: String contains numbers<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nstr_name = &quot;WelcomeUser1&quot;\nprint(str_name.isalpha())   # False\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">Case 3: String contains special characters<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nstr_name = &quot;WelcomeU$er@&quot;\nprint(str_name.isalpha())    # False\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">Case 4: String is empty<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nstr_name = &#039; &#039;\nprint(str_name.isalpha())    # False\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"> Program to Print List of All Possible Alpha Characters in Python <\/h2>\n\n\n\n<p>The Unicode module can be used to check the alpha characters. The program is to print all alpha Unicode characters.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport unicodedata\n\ntotal_count = 0\nfor i in range(2 ** 16):\n    charac = chr(i)\n    if charac.isalpha():\n        print(u&#039;{:04x}: {} ({})&#039;.format(i, charac, unicodedata.name(charac, &#039;UNNAMED&#039;)))\n        total_count = total_count + 1\nprint(&quot;Total Count of Alpha Unicode Characters = &quot;,total_count)\n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"527\" height=\"472\" src=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2019\/12\/Output-All-Alpha-Unicode-Characters.png\" alt=\"Output All Alpha Unicode Characters\" class=\"wp-image-1989\" srcset=\"https:\/\/www.askpython.com\/wp-content\/uploads\/2019\/12\/Output-All-Alpha-Unicode-Characters.png 527w, https:\/\/www.askpython.com\/wp-content\/uploads\/2019\/12\/Output-All-Alpha-Unicode-Characters-300x269.png 300w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><figcaption>Output All Alpha Unicode Characters<\/figcaption><\/figure>\n\n\n\n<p> It is just a glance of output as the actual output is lengthy. There are 48462 alpha characters in Unicode. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">References:<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Python String isalpha()<\/li><li><a class=\"rank-math-link rank-math-link\" href=\"https:\/\/docs.python.org\/3\/library\/stdtypes.html\" target=\"_blank\" rel=\"noopener\">Python Built-in String<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>String in Python has built-in functions for almost every action to be performed on a string. Python String isalpha() function checks for the alphabets in a string and returns True if the string consists of only alphabets (a-z, A-Z). Key Points : Return Type: Boolean i.e. True or False Parametric Values: No Parameters required Blank [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1926","post","type-post","status-publish","format-standard","hentry","category-string"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/posts\/1926","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/comments?post=1926"}],"version-history":[{"count":0,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/posts\/1926\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/media?parent=1926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/categories?post=1926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.askpython.com\/wp-json\/wp\/v2\/tags?post=1926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}