0

Why the output of this code is 2

a={0:1, 1:2} _sum= 0 for b in a: _sum += b Print(_sum)

14th Feb 2019, 10:04 AM
H.code
2 odpowiedzi
+ 3
The output isn't 2, it's 1. Try it in the code playground. _sum is the sum of the keys, i.e. 0 + 1 = 1 Make sure you change 'Print' to 'print' first 😉
14th Feb 2019, 10:23 AM
David Ashton
David Ashton - avatar
0
Well, the result is 1 and not 2
14th Feb 2019, 10:24 AM
KrOW
KrOW - avatar