How to get n variables in one line?
<p>I have a number <strong>n</strong> and I need to get from a user <strong>n</strong> variables in one line.</p>

<p>As far as i know, it's pretty easy to do if you know exactly how many variables you have.</p>

<pre><code>*variables* = map(int, input().split())
</code></pre>

<p>But if I don't know how many variables there are, what should I do?</p>

<p>Also, I'm asked to put the result in array. </p>

<p>Unfortunately, I've just started learning Python, so I have <em>absolutely</em> no idea how to do it and can't show any code I've tried. </p>

<p>User input being taken as a space separated string: </p>

<pre><code>1 2 3 4 5
</code></pre>

<p>This being the code you are dealing with: </p>

<pre><code>map(int, input().split())
</code></pre>

<p>Stating you need a list, then just store it in a single variable: </p>

<pre><code>inputs = map(int, input().split())
</code></pre>

<p>However, dealing with Python 3, you will end up with <code>map</code> object. So if you actually need a <code>list</code> type, then just call <code>list</code> on the <code>map</code> function:</p>

<pre><code>inputs = list(map(int, input().split()))
</code></pre>

<p>Demo:</p>

<pre><code>&gt;&gt;&gt; inputs = list(map(int, input().split()))
1 2 3 4 5
&gt;&gt;&gt; type(inputs)
&lt;class 'list'&gt;
&gt;&gt;&gt; inputs
[1, 2, 3, 4, 5]
</code></pre>

python