Sum of vectors does not give the expected result

0

I want to do the sum of two vectors and the truth is that I would not be walking the code. Can you help me?

This is the code I'm using:

""" 
Dados dos arreglos A y b N<15 elementos cada uno,
 calcular un arreglo C tal que c=a+b y Mostrarlo.

"""
va=[]
vb=[]
vc=[]
n=3 # tiene que ser n<15 (5 pq quiero)

for i in range (0,n+1,1): # cargo los de uno y despues los de otro . De lo contrario tardaria mas!!1
    va.append(int(input("ingresar los datos de los arreglos A ")))

for i in range (0,n+1,1):    
    vb.append(int(input("ingresar los datos de los arreglos B")))


for i in range (0,n+1,1):
    vc[i] = va[i] + vb[i]

print ("",vc[i])
    
asked by Ale Natale 07.11.2018 в 00:16
source

1 answer

0

Try this solution with the append function.

Example:

for i in range (0,n+1,1):
    vc.append(va[i] + vb[i])

print(vc)
    
answered by 07.11.2018 в 17:40