{"id":28034,"date":"2023-09-24T14:51:40","date_gmt":"2023-09-24T09:21:40","guid":{"rendered":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/?p=28034"},"modified":"2023-09-24T14:52:14","modified_gmt":"2023-09-24T09:22:14","slug":"python-input-vs-raw_input","status":"publish","type":"post","link":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/python-input-vs-raw_input\/","title":{"rendered":"Python input() Vs raw_input(): Which One to Choose?"},"content":{"rendered":"\n<p>You must have created Python codes asking for input from the user. Python provides multiple ways to facilitate the user in providing the input. Two of these methods are input and raw_input. Go through this blog to understand Python input vs raw_input.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_65 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/python-input-vs-raw_input\/#input_in_python\" title=\"input() in python\">input() in python<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/python-input-vs-raw_input\/#Syntax_of_input\" title=\"Syntax of input()\">Syntax of input()<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/python-input-vs-raw_input\/#Working_of_input\" title=\"Working of input()\">Working of input()<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/python-input-vs-raw_input\/#raw_input_in_python\" title=\"raw_input in python\">raw_input in python<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/python-input-vs-raw_input\/#Syntax_of_raw_input\" title=\"Syntax of raw_input()\">Syntax of raw_input()<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/python-input-vs-raw_input\/#input_vs_raw_input\" title=\"input vs raw_input\">input vs raw_input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/python-input-vs-raw_input\/#Is_input_better_than_raw_input\" title=\"Is input better than raw_input?\">Is input better than raw_input?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/python-input-vs-raw_input\/#Handling_input\" title=\"Handling input()\">Handling input()<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/python-input-vs-raw_input\/#Undefined_raw_input\" title=\"Undefined raw_input \">Undefined raw_input <\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pythonpool.com\/python-input-vs-raw_input\/#Usage_of_input_raw_input\" title=\"Usage of input()\/ raw_input()\">Usage of input()\/ raw_input()<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.pythonpool.com\/python-input-vs-raw_input\/#FAQS\" title=\"FAQS\">FAQS<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.pythonpool.com\/python-input-vs-raw_input\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.pythonpool.com\/python-input-vs-raw_input\/#Trending_Python_Articles\" title=\"Trending Python Articles\">Trending Python Articles<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-input-in-python\"><span class=\"ez-toc-section\" id=\"input_in_python\"><\/span>input() in python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The input() function in Python 3 fetches the input from the user in the form of a prompt.  Then, it changes the user-entered input to string format. This is usually saved in a variable. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-syntax-of-input\"><span class=\"ez-toc-section\" id=\"Syntax_of_input\"><\/span>Syntax of input()<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>One just needs to specify the prompt after writing the input keyword. The given piece of code depicts the syntax of the input() function:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\ninput(&#x5B;prompt])\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-working-of-input\"><span class=\"ez-toc-section\" id=\"Working_of_input\"><\/span>Working of input()<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Let&#8217;s consider an example:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nn = input(&quot;Enter your name: &quot;)\nprint(f&quot;It is {n}!&quot;)\n<\/pre><\/div>\n\n\n<p>This will generate the given output:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nEnter your name: Sara\nIt is Sara!\n<\/pre><\/div>\n\n\n<p>The accepted format is usually a string. However, you can change it to either <a href=\"https:\/\/www.pythonpool.com\/int-to-float-python\/\" target=\"_blank\" rel=\"noopener\">int or float<\/a> by specifying that before accepting the prompt. This function makes use of the eval() method.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nage = int(input(&quot;Enter the age: &quot;))\nprint(f&quot;It is {age}!&quot;)\n#this accepts integer type age\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-raw-input-in-python\"><span class=\"ez-toc-section\" id=\"raw_input_in_python\"><\/span><strong>raw_input<\/strong> in python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Similar to the input() function, the raw_input() of Python 2 also accepts a string-based answer from the user for a particular prompt.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-syntax-of-raw-input\"><span class=\"ez-toc-section\" id=\"Syntax_of_raw_input\"><\/span>Syntax of raw_input()<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Let&#8217;s have a look at the syntax of the raw_input() function.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nraw_input(&#x5B;prompt])\n<\/pre><\/div>\n\n\n<p>You may comprehend this with the help of an example:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nname = raw_input(&quot;Enter your nickname &quot;)\n# Print the output with name formatting\nprint(&quot;Hi there, {}!&quot;.format(name))\n<\/pre><\/div>\n\n\n<p>Executing this piece of code gives the following output:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nEnter your nickname Sam\nHi there, Sam!\n<\/pre><\/div>\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-golf monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Popular now<\/span><span class=\"monsterinsights-inline-popular-posts-border\" ><\/span><span class=\"monsterinsights-inline-popular-posts-border-2\" ><\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\">[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-input-vs-raw-input\"><span class=\"ez-toc-section\" id=\"input_vs_raw_input\"><\/span>input vs raw_input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The given table draws a list of differences between the two functions: input and raw_input.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">input()<\/th><th class=\"has-text-align-center\" data-align=\"center\">raw_input()<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">It is mostly used in Python3.<\/td><td class=\"has-text-align-center\" data-align=\"center\">It is mostly used in Python2.<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">It considers the prompt in the form of an expression.<\/td><td class=\"has-text-align-center\" data-align=\"center\">It doesn&#8217;t consider the prompt in the form of an expression.<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">It doesn&#8217;t accept the prompt as a string.<\/td><td class=\"has-text-align-center\" data-align=\"center\">It accepts the prompt as a string.<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">It can be dangerous to use.<\/td><td class=\"has-text-align-center\" data-align=\"center\">It is safer.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-is-input-better-than-raw-input\"><span class=\"ez-toc-section\" id=\"Is_input_better_than_raw_input\"><\/span>Is input better than raw_input?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>While input() evaluates the prompt, raw_input() takes it as an expression only. In Python 2, both work in the same manner. They don&#8217;t evaluate the expression. However, in Python 3, it is better to use raw_input() because input() accepts an integer, a float, or a string and formulates an expression. A user may enter a disruptive code, too. This is not a safe approach. Therefore, programmers prefer raw_input().<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-handling-input\"><span class=\"ez-toc-section\" id=\"Handling_input\"><\/span>Handling input()<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You might have to know that the input() function may prove to be malicious if it is not used wisely. <\/p>\n\n\n\n<ul>\n<li>In case there&#8217;s a form or any such resource wherein the user has to enter some information, try avoiding the input() function. That&#8217;s because a user may enter something that can harm the system as input() will directly evaluate it.<\/li>\n\n\n\n<li>Use HTML parsing in case you want to opt for input() with user-controlled software.<\/li>\n\n\n\n<li>You should avoid using this&nbsp;function with file operations, too.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-undefined-raw-input\"><span class=\"ez-toc-section\" id=\"Undefined_raw_input\"><\/span>Undefined <strong>raw_input <\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In Python 3, raw_input() doesn&#8217;t work. Python 3 supports the input() function. The given piece of code helps to check the version of Python in case you are unsure about it. The output screen displays a NameError if you use the raw_input() function with Python 3.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport sys\nprint(sys.version)\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-usage-of-input-raw-input\"><span class=\"ez-toc-section\" id=\"Usage_of_input_raw_input\"><\/span>Usage of input()\/ raw_input()<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>It is used for a variety of purposes:<\/p>\n\n\n\n<ul>\n<li>Calculator code, which accepts numbers for finding mathematical operations<\/li>\n\n\n\n<li>Guess the number of games in Python.<\/li>\n\n\n\n<li>File operations<\/li>\n\n\n\n<li>Create a &nbsp;menu-driven program\/ command-line interpreter.<\/li>\n<\/ul>\n\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-alpha monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Trending<\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\">[Fixed] nameerror: name Unicode is not defined<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-faqs\"><span class=\"ez-toc-section\" id=\"FAQS\"><\/span>FAQS<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1695127303201\"><strong class=\"schema-faq-question\">Why did Python 3 accept input() instead of raw_input()?<\/strong> <p class=\"schema-faq-answer\">This was done to maintain consistency. Initially, python 2 had both functions, and it created some sort of confusion. <\/p> <\/div> <\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This blog covers the difference between 2 widely used Python functions to accept user inputs. These are input() and raw_input(). It also discusses the syntax associated with each one of them and their usage. Besides this, it also lays emphasis on the different ways in which input() can be used efficiently.<\/p>\n\n\n<div class=\"monsterinsights-widget-popular-posts monsterinsights-widget-popular-posts-delta monsterinsights-popular-posts-styled monsterinsights-widget-popular-posts-columns-2\"><h2 class=\"monsterinsights-widget-popular-posts-widget-title\"><span class=\"ez-toc-section\" id=\"Trending_Python_Articles\"><\/span>Trending Python Articles<span class=\"ez-toc-section-end\"><\/span><\/h2><ul class=\"monsterinsights-widget-popular-posts-list\"><li ><a href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/typeerror-cant-compare-datetime.datetime-to-datetime.date_.webp 1200w \" alt=\"[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 11, 2024<\/span><\/div><\/div><\/a><\/li><li ><a href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\"><div class=\"monsterinsights-widget-popular-posts-image\"><img decoding=\"async\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp\" srcset=\" https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-300x157.webp 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-1024x536.webp 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined-768x402.webp 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2024\/01\/Fixed-nameerror-name-Unicode-is-not-defined.webp 1200w \" alt=\"[Fixed] nameerror: name Unicode is not defined\" \/><\/div><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" >[Fixed] nameerror: name Unicode is not defined<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><span class=\"monsterinsights-widget-popular-posts-author\">by Namrata Gulati<\/span><span>&#9679;<\/span><span class=\"monsterinsights-widget-popular-posts-date\">January 2, 2024<\/span><\/div><\/div><\/a><\/li><\/ul><\/div><p><\/p>","protected":false},"excerpt":{"rendered":"<p>You must have created Python codes asking for input from the user. Python provides multiple ways to facilitate the user in providing the input. Two &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Python input() Vs raw_input(): Which One to Choose?\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/python-input-vs-raw_input\/#more-28034\" aria-label=\"More on Python input() Vs raw_input(): Which One to Choose?\">Read more<\/a><\/p>\n","protected":false},"author":38,"featured_media":28240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4047],"tags":[5833,5831,5830,5834,5832],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v22.4) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python input() Vs raw_input(): Which One to Choose?<\/title>\n<meta name=\"description\" content=\"This blog covers the difference between 2 widely used python functions to accept user inputs: input() and raw_input().\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python input() Vs raw_input(): Which One to Choose?\" \/>\n<meta property=\"og:description\" content=\"You must have created Python codes asking for input from the user. Python provides multiple ways to facilitate the user in providing the input. Two of\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2023-09-24T09:21:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-24T09:22:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com.dream.website\/wp-content\/uploads\/2023\/09\/python-input-vs-raw_input.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Namrata Gulati\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Namrata Gulati\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/\"},\"author\":{\"name\":\"Namrata Gulati\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/294338f378f0853e6af4ca4a5a907ea6\"},\"headline\":\"Python input() Vs raw_input(): Which One to Choose?\",\"datePublished\":\"2023-09-24T09:21:40+00:00\",\"dateModified\":\"2023-09-24T09:22:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/\"},\"wordCount\":630,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2023\/09\/python-input-vs-raw_input.webp\",\"keywords\":[\"input vs raw_input in python\",\"python 3 input vs raw_input\",\"python input and raw_input\",\"python raw_input coding\",\"raw_input vs input\"],\"articleSection\":[\"Comparison\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#respond\"]}]},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/\",\"url\":\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/\",\"name\":\"Python input() Vs raw_input(): Which One to Choose?\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2023\/09\/python-input-vs-raw_input.webp\",\"datePublished\":\"2023-09-24T09:21:40+00:00\",\"dateModified\":\"2023-09-24T09:22:14+00:00\",\"description\":\"This blog covers the difference between 2 widely used python functions to accept user inputs: input() and raw_input().\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#faq-question-1695127303201\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2023\/09\/python-input-vs-raw_input.webp\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2023\/09\/python-input-vs-raw_input.webp\",\"width\":1200,\"height\":628,\"caption\":\"python input vs raw_input\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python input() Vs raw_input(): Which One to Choose?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/twitter.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/294338f378f0853e6af4ca4a5a907ea6\",\"name\":\"Namrata Gulati\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/dc6f5902e9f3e850d24d16532c60effe?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/dc6f5902e9f3e850d24d16532c60effe?s=96&d=wavatar&r=g\",\"caption\":\"Namrata Gulati\"}},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#faq-question-1695127303201\",\"position\":1,\"url\":\"https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#faq-question-1695127303201\",\"name\":\"Why did Python 3 accept input() instead of raw_input()?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"This was done to maintain consistency. Initially, python 2 had both functions, and it created some sort of confusion. \",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python input() Vs raw_input(): Which One to Choose?","description":"This blog covers the difference between 2 widely used python functions to accept user inputs: input() and raw_input().","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/","og_locale":"en_US","og_type":"article","og_title":"Python input() Vs raw_input(): Which One to Choose?","og_description":"You must have created Python codes asking for input from the user. Python provides multiple ways to facilitate the user in providing the input. Two of","og_url":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/","og_site_name":"Python Pool","article_published_time":"2023-09-24T09:21:40+00:00","article_modified_time":"2023-09-24T09:22:14+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/wp-content\/uploads\/2023\/09\/python-input-vs-raw_input.webp","type":"image\/webp"}],"author":"Namrata Gulati","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Namrata Gulati","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#article","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/"},"author":{"name":"Namrata Gulati","@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/#\/schema\/person\/294338f378f0853e6af4ca4a5a907ea6"},"headline":"Python input() Vs raw_input(): Which One to Choose?","datePublished":"2023-09-24T09:21:40+00:00","dateModified":"2023-09-24T09:22:14+00:00","mainEntityOfPage":{"@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/"},"wordCount":630,"commentCount":0,"publisher":{"@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#primaryimage"},"thumbnailUrl":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2023\/09\/python-input-vs-raw_input.webp","keywords":["input vs raw_input in python","python 3 input vs raw_input","python input and raw_input","python raw_input coding","raw_input vs input"],"articleSection":["Comparison"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#respond"]}]},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/","url":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/","name":"Python input() Vs raw_input(): Which One to Choose?","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#primaryimage"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#primaryimage"},"thumbnailUrl":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2023\/09\/python-input-vs-raw_input.webp","datePublished":"2023-09-24T09:21:40+00:00","dateModified":"2023-09-24T09:22:14+00:00","description":"This blog covers the difference between 2 widely used python functions to accept user inputs: input() and raw_input().","breadcrumb":{"@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#faq-question-1695127303201"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#primaryimage","url":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2023\/09\/python-input-vs-raw_input.webp","contentUrl":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2023\/09\/python-input-vs-raw_input.webp","width":1200,"height":628,"caption":"python input vs raw_input"},{"@type":"BreadcrumbList","@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Python input() Vs raw_input(): Which One to Choose?"}]},{"@type":"WebSite","@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/#website","url":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/twitter.com\/pythonpool","https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/#\/schema\/person\/294338f378f0853e6af4ca4a5a907ea6","name":"Namrata Gulati","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/secure.gravatar.com\/avatar\/dc6f5902e9f3e850d24d16532c60effe?s=96&d=wavatar&r=g","contentUrl":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/secure.gravatar.com\/avatar\/dc6f5902e9f3e850d24d16532c60effe?s=96&d=wavatar&r=g","caption":"Namrata Gulati"}},{"@type":"Question","@id":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#faq-question-1695127303201","position":1,"url":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com.dream.website\/python-input-vs-raw_input\/#faq-question-1695127303201","name":"Why did Python 3 accept input() instead of raw_input()?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"This was done to maintain consistency. Initially, python 2 had both functions, and it created some sort of confusion. ","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/28034"}],"collection":[{"href":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=28034"}],"version-history":[{"count":51,"href":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/28034\/revisions"}],"predecessor-version":[{"id":28252,"href":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/28034\/revisions\/28252"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/28240"}],"wp:attachment":[{"href":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=28034"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=28034"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=28034"}],"curies":[{"name":"wp","href":"https:\/\/web.archive.org\/web\/20240926033406\/https:\/\/api.w.org\/{rel}","templated":true}]}}