+ 3

That's odd

2nd pass other fail len = int(input()) sum = 0 for i in range(len): num = int(input ()) if num % 2 == 0: sum = sum +num print(sum)

31st May 2020, 3:02 AM
Swapnil Bhakare
Swapnil Bhakare - avatar
9 Antworten
+ 8
input() does not work in loops in sololearn, all should be given as soon as the program starts running.
31st May 2020, 3:13 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 2
I solved it
31st May 2020, 6:46 AM
Swapnil Bhakare
Swapnil Bhakare - avatar
+ 1
num=int(input()) sum=0 for i in range(num): num=int(input()) if (num%2!=0): sum=sum+num print(sum) """" int sum = 0; for(int i=0;i<=num;i++) { if(num%2!=0) { sum=sum+num; print(sum) } } """" int sum = 0; int i= 0; while(num%2!=0) { sum=sum+num; i=i+1; print(sum); } """"
18th Nov 2022, 7:36 PM
Anita chaubey
Anita chaubey - avatar
0
Your error is that you are printing the local value of the var sum so it will repeat the value everytime the loop find a even number. Reorder your code like this: len = int(input()) sum = 0 for i in range(len): num = int(input ()) if num % 2 == 0: sum = sum +num print(sum)
14th May 2021, 9:27 AM
Maxwell D. Dorliea
Maxwell D. Dorliea - avatar
0
This is how i did it. List = [] n = int(input()) for i in range(0, n): ele = int(input()) List.append(ele) t = [num for num in List if num % 2 ==0] print(sum(t))
17th Dec 2021, 9:45 PM
Samnith Vath
Samnith Vath - avatar
0
num=int(input()) sum=0 for i in range(num): num=int(input()) if (num%2!=0): sum=sum+num print(sum) """" int sum = 0; for(int i=0;i<=num;i++) { if(num%2!=0) { sum=sum+num; print(sum) } } """" int sum = 0; int i= 0; while(num%2!=0) { sum=sum+num; i=i+1; print(sum); } """"
18th Nov 2022, 7:36 PM
Anita chaubey
Anita chaubey - avatar
0
num=int(input()) sum=0 for i in range(num): num=int(input()) if (num%2!=0): sum=sum+num print(sum) """" int sum = 0; for(int i=0;i<=num;i++) { if(num%2!=0) { sum=sum+num; print(sum) } } """" int sum = 0; int i= 0; while(num%2!=0) { sum=sum+num; i=i+1; print(sum); } """"
18th Nov 2022, 7:36 PM
Anita chaubey
Anita chaubey - avatar
0
num=int(input()) sum=0 for i in range(num): num=int(input()) if (num%2!=0): sum=sum+num print(sum) """" int sum = 0; for(int i=0;i<=num;i++) { if(num%2!=0) { sum=sum+num; print(sum) } } """" int sum = 0; int i= 0; while(num%2!=0) { sum=sum+num; i=i+1; print(sum); } """"
18th Nov 2022, 7:36 PM
Anita chaubey
Anita chaubey - avatar