I dont know how to put multiple input to a list can u help me? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I dont know how to put multiple input to a list can u help me?

num=input() sum=0 for x in num : if int(x) %2 ==0 : sum+=int(x) print(sum) I have to take multiple input and cuclate sum of them but it count only the first num as input i tryed list(input()) but didnt work

24th Nov 2022, 5:49 AM
Parsa Nazer
Parsa Nazer - avatar
2 Answers
+ 5
input accepts only string value so if you want to take multiple inputs you have to take inputs with space like 1 2 3 4 5 6 inp = input() lis = inp.split(' ') This will give list Or your number of inputs should be fix: like take 5 inputs So in this case you can use loop: x = int(input()) i = 0 lis = [] while i < x: lis.append(int(input()) i += 1 print (lis)
24th Nov 2022, 6:00 AM
A͢J
A͢J - avatar
+ 3
Parsa Nazer Please move your code link into post Description, links do not work if you put them in post title or tags https://code.sololearn.com/W3uiji9X28C1/?ref=app
24th Nov 2022, 9:40 AM
Ipang