0
why the output of this code is 4?
nums = [1, 2, 3, 4] res = 0 for x in nums: if (x % 2 == 0): continue else: res += x print(res)
3 Answers
+ 3
i believe this code output the sum of the odd numbers from the list
here 1+3
+ 3
1 % 2 != 0 â>
res = 0 + 1
2 % 2 = 0 â> continue
3 % 2 != 0 â> res = 1 + 3
print(res)
+ 3
Please use relevant tags ...
https://code.sololearn.com/W3uiji9X28C1/?ref=app