0

need help for input-command | input from user needs to be multipleline | vectoraddition

hey guys. tried some vectoraddition, sadly the input is made all at once. seems i missed something for the input command. i want the code to read every component each, or at least per vector anybody knows stuff and can help? code -> #vectoraddition print('plz give me vector a!') a_1=input('first component of vector a:') a_2=input('second component:') a_3=input('third component:') a=[float(a_1),float(a_2),float(a_3)] print(a) print('plz give me vector b!') b_1=input('first component of vector b:') b_2=input('second component:') b_3=input('third component:') b=[float(b_1),float(b_2),float(b_3)] print(b) c=[0,0,0] i=0 while i<3: c[i]=a[i]+b[i] i+=1 print(c) <- code and perhaps as a second question, is it possible to read the vectorcomponents iteratively: e.g. n=0 a=[0,0,0] while n<2: a[n]=input('n'+'component:') n+=1 My example doesnt work as you guys probably see. :/

6th Oct 2016, 10:09 AM
Max Grove
Max Grove - avatar
4 Respuestas
+ 1
Hi, what are you using to compile your code?
6th Oct 2016, 8:47 PM
Fhatuwani Luvhengo
Fhatuwani Luvhengo - avatar
+ 1
What do you mean by "input is made all at once" For me your code works fine. Do you have python installed in your computer or are you using any online interpreter. In case of most of the online interpreter, including sololearn, you are required to input all the inputs at once
7th Oct 2016, 4:57 AM
Rohit Kumar
0
anyone can help?
6th Oct 2016, 6:46 PM
Max Grove
Max Grove - avatar
0
i just installed qpython for my phone. its working in the console. thanks mate ur question helped me recognize that i should run the code in a console. i used the run-tool in here. in console it works like i wanted it to! my bad i didnt think about it *blush* :D
6th Oct 2016, 8:51 PM
Max Grove
Max Grove - avatar