Still having some error..pls help me for exact solution | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Still having some error..pls help me for exact solution

Still having some error..https://www.sololearn.com/coach/63?ref=app https://code.sololearn.com/coh91S6iKWc9/?ref=app

17th Jun 2020, 5:47 PM
richa shrivastava
richa shrivastava - avatar
5 Answers
+ 4
You are just taking the count of input and passing it to the range. Read the question again. The 1st input is the number of elements to be entered and it is followed by the values to be checked whether odd or even. n = int(input()) sum = 0 for i in range(n): num = int(input()) if num%2==0: sum = sum+num print(sum)
17th Jun 2020, 5:56 PM
Avinesh
Avinesh - avatar
+ 3
n takes the number of elements. Suppose it is 8. So you will enter 8 elements one by one. To do this you use a for loop to iterate and take a new input each time and evaluate if it is true or not. for i in range(8): Now if the 1st input is 2, it is stored in num and you check if it is divisible by 2, if yes then you add it to sum. Now the loop moves to next iteration and a new value is entered. The same check is done till all the values are evaluated. All the test cases are automatically generated so you just have to write the logic for it to work.
17th Jun 2020, 6:18 PM
Avinesh
Avinesh - avatar
+ 1
What is the error? because it outputs right answer
17th Jun 2020, 5:49 PM
Abhay
Abhay - avatar
+ 1
still I am confused..
17th Jun 2020, 6:12 PM
richa shrivastava
richa shrivastava - avatar
0
richa shrivastava My messaging function is currently down, you might have understood it by now but I would still leave a comment regarding the question you asked. I have explained it in the code. https://code.sololearn.com/cGdnhwkK8b56/?ref=app
25th Jun 2020, 2:59 PM
Avinesh
Avinesh - avatar