Python Code Error
<p>What's wrong with this program in Python? </p>

<p>I need to take an integer input(N) - accordingly, I need to create an array of (N)integers, taking integers also as input. Finally, I need to print the sum of all the integers in the array.</p>

<p>The input is in this format: </p>

<pre><code>5

4 6 8 18 96
</code></pre>

<p>This is the code I wrote : </p>

<pre><code>N = int(input().split())
i=0
s = 0
V=[]
if N&lt;=100 :
    for i in range (0,N):
        x = int(input().split())
        V.append(x)
        i+=1
        s+=x
print (s)
</code></pre>

<p>Its showing the following error.</p>

<pre><code>Traceback (most recent call last): 
  File "main.py", line 1, in &lt;module&gt;
N = int(input().split())
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'
</code></pre>

<p>You could use sys module to take the input when calling the program and a lambda function to convert the string items in list to integers. You could also make use of the built-in sum function. Something like that:</p>

<pre><code>#!/usr/bin/env python

import sys
s = sum(i for i in map(lambda x: int(x), sys.argv[1].split(',')))
print s
</code></pre>

<p>Example:</p>

<pre><code>python test.py 1,2,3,4
</code></pre>

<p>The output should be <strong>10</strong>.</p>

<blockquote>
  <p>Modifying your code:</p>
</blockquote>

<p>Now, if you want to modify your code to do what it intends to do, you could modify your code like that:</p>

<pre><code>#!/usr/bin/env python

N = input()
s = 0
V=[]
if N&lt;=100 :
    for i in range (0,N):
        x = input()
        V.append(x)
        s+=x
print (s)
</code></pre>

<p><strong>Note 1</strong>: In python when you use range you don't have to manually increase the counter in the loop, it happens by default.</p>

<p><strong>Note 2</strong>: the '<code>input()</code>' function will maintain the type of the variable you will enter, so if you enter an integer you don't have to convert it to integer. (Have in mind that <code>input()</code> is <strong>not recommended to use</strong> as it can be dangerous in more complicated projects).</p>

<p><strong>Note 3</strong>: You don't need to use '<code>.split()</code>' for your input.</p>

python