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
5 Réponses
+ 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)
+ 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.
+ 1
What is the error? because it outputs right answer
+ 1
still I am confused..
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