{"id":23028,"date":"2021-12-24T12:31:52","date_gmt":"2021-12-24T07:01:52","guid":{"rendered":"https:\/\/tutorial.eyehunts.com\/?p=23028"},"modified":"2023-10-25T19:07:40","modified_gmt":"2023-10-25T13:37:40","slug":"how-to-take-n-number-of-inputs-in-python-example-code","status":"publish","type":"post","link":"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/","title":{"rendered":"How to take n number of inputs in Python | Example code"},"content":{"rendered":"\n<p>Use <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-map-function-data-structure-example\/\">map() function<\/a> and <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-split-function-python-split-string\/\">split() function<\/a> to take n number of inputs in Python.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>list(map(int, input().split()&#91;:N]))<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>input()<\/strong>: takes user input.<\/li>\n\n\n\n<li><strong>split()<\/strong>: Splitting the string into a sequence of elements means converting whitespace into commas (,), a split function applicable only for the string data type.<\/li>\n\n\n\n<li><strong>map()<\/strong>: takes 2 arguments 1st one is a function and 2nd one is sequence of numbers.<\/li>\n\n\n\n<li><strong>list<\/strong>: this is the container to store the elements.<\/li>\n\n\n\n<li><strong>append<\/strong>(): adding elements at the end.<\/li>\n<\/ul>\n\n\n\n<p>If the numbers are provided in the same line then you can use,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>arr = list(map(int, input().split()))<\/code><\/pre>\n\n\n\n<p>If inputs are in different lines then,<\/p>\n\n\n\n<p><code>arr = [ int(input()) for i in range(n)]<\/code><\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Example take n number of inputs in Python<\/h2>\n\n\n\n<p>Simple example code.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>arr = list(map(int, input().split()))\n\nprint(arr)<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"253\" height=\"116\" src=\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/How-to-take-n-number-of-inputs-in-Python.jpg?resize=253%2C116&#038;ssl=1\" alt=\"How to take n number of inputs in Python\" class=\"wp-image-23761\"\/><\/figure><\/div>\n\n\n<p>If the user wants to select how many numbers then enter.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>n = int(input(\"Enter number of elements : \"))\n\n# Below line read inputs from user using map() function\na = list(map(int, input(\"\\nEnter the numbers : \").strip().split()))&#91;:n]\n\nprint(\"\\nList is - \", a)<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>: <\/p>\n\n\n\n<p>Enter the number of elements: 2<\/p>\n\n\n\n<p>Enter the numbers: 1 2<\/p>\n\n\n\n<p>List is &#8211; [1, 2]<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Using a list comprehension: <\/strong>You can use a list comprehension to take n inputs and store them in a list:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>n = int(input(\"Enter the number of inputs: \"))\r\ninputs = &#91;input(f\"Enter input {i + 1}: \") for i in range(n)]\r\n\r\nprint(\"You entered:\", inputs)\r<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Do comment if you have any doubts or suggestions on this Python input topic.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note:<\/strong> IDE:&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.jetbrains.com\/pycharm\/\" target=\"_blank\">PyCharm<\/a>&nbsp;2021.3.3 (Community Edition)<\/p><p>Windows 10<\/p><p><strong>Python 3.10.1<\/strong><\/p><p>All<strong>&nbsp;Python Examples&nbsp;are in&nbsp;Python&nbsp;3<\/strong>, so Maybe its different from python 2 or upgraded versions.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Use map() function and split() function to take n number of inputs in Python. If the numbers are provided in the same line then you can use, If inputs are in different lines then, arr = [ int(input()) for i in range(n)] Example take n number of inputs in Python Simple example code. Output: If&hellip;&nbsp;<a href=\"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">How to take n number of inputs in Python | Example code<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[30],"tags":[263,103],"post_series":[],"class_list":["post-23028","post","type-post","status-publish","format-standard","hentry","category-python","tag-python-input","tag-python-number"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to take n number of inputs in Python | Example code<\/title>\n<meta name=\"description\" content=\"Use map() function and split() function to take n number of inputs in Python. If the user wants to select how many numbers want to enter..\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to take n number of inputs in Python | Example code\" \/>\n<meta property=\"og:description\" content=\"Use map() function and split() function to take n number of inputs in Python. If the user wants to select how many numbers want to enter..\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-24T07:01:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-25T13:37:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/How-to-take-n-number-of-inputs-in-Python.jpg\" \/>\n<meta name=\"author\" content=\"Rohit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rohit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/\",\"name\":\"How to take n number of inputs in Python | Example code\",\"isPartOf\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/How-to-take-n-number-of-inputs-in-Python.jpg\",\"datePublished\":\"2021-12-24T07:01:52+00:00\",\"dateModified\":\"2023-10-25T13:37:40+00:00\",\"author\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\"},\"description\":\"Use map() function and split() function to take n number of inputs in Python. If the user wants to select how many numbers want to enter..\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/How-to-take-n-number-of-inputs-in-Python.jpg?fit=253%2C116&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/How-to-take-n-number-of-inputs-in-Python.jpg?fit=253%2C116&ssl=1\",\"width\":253,\"height\":116},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorial.eyehunts.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to take n number of inputs in Python | Example code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\",\"url\":\"https:\/\/tutorial.eyehunts.com\/\",\"name\":\"Tutorial\",\"description\":\"By EyeHunts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\",\"name\":\"Rohit\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777979855\",\"contentUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777979855\",\"caption\":\"Rohit\"},\"description\":\"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.\",\"url\":\"https:\/\/tutorial.eyehunts.com\/author\/rohit\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to take n number of inputs in Python | Example code","description":"Use map() function and split() function to take n number of inputs in Python. If the user wants to select how many numbers want to enter..","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:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/","og_locale":"en_US","og_type":"article","og_title":"How to take n number of inputs in Python | Example code","og_description":"Use map() function and split() function to take n number of inputs in Python. If the user wants to select how many numbers want to enter..","og_url":"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/","og_site_name":"Tutorial","article_published_time":"2021-12-24T07:01:52+00:00","article_modified_time":"2023-10-25T13:37:40+00:00","og_image":[{"url":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/How-to-take-n-number-of-inputs-in-Python.jpg","type":"","width":"","height":""}],"author":"Rohit","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rohit","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/","url":"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/","name":"How to take n number of inputs in Python | Example code","isPartOf":{"@id":"https:\/\/tutorial.eyehunts.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/#primaryimage"},"image":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/#primaryimage"},"thumbnailUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/How-to-take-n-number-of-inputs-in-Python.jpg","datePublished":"2021-12-24T07:01:52+00:00","dateModified":"2023-10-25T13:37:40+00:00","author":{"@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1"},"description":"Use map() function and split() function to take n number of inputs in Python. If the user wants to select how many numbers want to enter..","breadcrumb":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/#primaryimage","url":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/How-to-take-n-number-of-inputs-in-Python.jpg?fit=253%2C116&ssl=1","contentUrl":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/How-to-take-n-number-of-inputs-in-Python.jpg?fit=253%2C116&ssl=1","width":253,"height":116},{"@type":"BreadcrumbList","@id":"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-number-of-inputs-in-python-example-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorial.eyehunts.com\/"},{"@type":"ListItem","position":2,"name":"How to take n number of inputs in Python | Example code"}]},{"@type":"WebSite","@id":"https:\/\/tutorial.eyehunts.com\/#website","url":"https:\/\/tutorial.eyehunts.com\/","name":"Tutorial","description":"By EyeHunts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1","name":"Rohit","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/","url":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777979855","contentUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777979855","caption":"Rohit"},"description":"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.","url":"https:\/\/tutorial.eyehunts.com\/author\/rohit\/"}]}},"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":22590,"url":"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-array-input-in-python-example-code\/","url_meta":{"origin":23028,"position":0},"title":"How to take array input in Python | Example code","author":"Rohit","date":"November 21, 2021","format":false,"excerpt":"Using the map()\u00a0function and input() function we can take array input from the user in Python. Simply read inputs from the user using the map() function and convert them into the list (Array). Using the input() function and converting the input into an array: array = input(\"Enter space-separated elements: \").split()\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"How to take array input in Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/How-to-take-array-input-in-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":23148,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-create-a-list-from-user-input-example-code\/","url_meta":{"origin":23028,"position":1},"title":"Python create a list from user input | Example code","author":"Rohit","date":"December 13, 2021","format":false,"excerpt":"Use an input() function with split() function to split an input string by space and splits a string into a list to create a list from user input in Python. Example create a list from user input in Python Simple example code gets a list of numbers as input from\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python creates a list from user input","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/Python-creates-a-list-from-user-input.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/Python-creates-a-list-from-user-input.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/Python-creates-a-list-from-user-input.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":23070,"url":"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-list-input-in-python-in-single-line-example-code\/","url_meta":{"origin":23028,"position":2},"title":"How to take list input in Python in single line | Example code","author":"Rohit","date":"December 11, 2021","format":false,"excerpt":"To take list input in Python in a single line use input() function and split() function. Where the input() function accepts a string, integer, and character input from a user, and the split() function splits an input string by space. # Method 1: Using list comprehension input_list = [int(x) for\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"How to take list input in Python in single line","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/How-to-take-list-input-in-Python-in-single-line.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":23041,"url":"https:\/\/tutorial.eyehunts.com\/python\/input-split-python-example-code\/","url_meta":{"origin":23028,"position":3},"title":"Input split Python | Example code","author":"Rohit","date":"December 9, 2021","format":false,"excerpt":"If you want to split input by space or any other splitter then just use the split method with the input function in Python. split slits a string by a space by default, but you can change this behavior: input().split(separator, maxsplit) separator (optional): The delimiter on which the string will\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Input split Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/Input-split-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":23068,"url":"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-integer-array-input-in-python-example-code\/","url_meta":{"origin":23028,"position":4},"title":"How to take integer array input in Python | Example code","author":"Rohit","date":"December 13, 2021","format":false,"excerpt":"It's very easy to take array input in Python. Use input() function with map and split() functions. Example take array input in Python Simple example code. If the numbers are provided in the same line then you can use them using a map(). arr = list(map(int, input().split())) print(arr) Output: If\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"How to take integer array input in Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/How-to-take-integer-array-input-in-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":23060,"url":"https:\/\/tutorial.eyehunts.com\/python\/how-to-take-n-inputs-in-one-line-in-python-example-code\/","url_meta":{"origin":23028,"position":5},"title":"How to take n inputs in one line in Python | Example code","author":"Rohit","date":"December 13, 2021","format":false,"excerpt":"You can use a list comprehension to take n inputs in one line in Python. The input string is split into n parts, then the list comp creates a new list by applying int() to each of them. Example take n inputs in one line in Python Simple example code\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"How to take n inputs in one line in Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/How-to-take-n-inputs-in-one-line-in-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/23028","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/comments?post=23028"}],"version-history":[{"count":1,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/23028\/revisions"}],"predecessor-version":[{"id":42085,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/23028\/revisions\/42085"}],"wp:attachment":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/media?parent=23028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/categories?post=23028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/tags?post=23028"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/post_series?post=23028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}