0

Python continue, what is going wrong?

Hello Python pros, Where is my code wrong? I am dong a challenge problem and the answer is supposed to be 6026 but mine is comimg out to 4920 or something. The problem states that it should skip the odd numbers and only sum the even ones. https://code.sololearn.com/c9hy8d1olv4L/?ref=app

23rd Jan 2021, 2:27 PM
Steve Barone
Steve Barone - avatar
6 Respostas
+ 4
if num % 2 != 0:
23rd Jan 2021, 2:30 PM
Abhay
Abhay - avatar
+ 5
items_list = [23, 555, 666, 123, 128, 4242, 990] sum_of_even = 0 for item in items_list: if item % 2 == 0: sum_of_even += item print(sum_of_even) i make good result with this one (=6026)
23rd Jan 2021, 3:17 PM
Jan P.E. Steinert
Jan P.E. Steinert - avatar
+ 2
ah of course thank you! its the easy things like that, that get missed hehe. appreciate it!
23rd Jan 2021, 2:46 PM
Steve Barone
Steve Barone - avatar
+ 2
thanks for the different method Jan P.E. Steinert
23rd Jan 2021, 3:29 PM
Steve Barone
Steve Barone - avatar
+ 1
Would be great if you could mark my answer as correct too. :-D
25th Jan 2021, 12:46 AM
Jan P.E. Steinert
Jan P.E. Steinert - avatar
0
thanks Jan P.E. Steinert i will give it a try and see!
26th Jan 2021, 2:53 AM
Steve Barone
Steve Barone - avatar