+ 2
What is the output of this code ?
dict={1:15,5:10,4:26} sum=0 for value in dict : sum=sum+value print(sum)
2 Answers
+ 6
It's output is 10. Because during the execution of "for loop" every time key will be extracted from dict and get added to sum.
sum=0+1 = 1
sum=1+5 = 6
sum=6+4 = 10
+ 1
10, because it adds the keys, not the values: 0 + 1 + 5 + 4 = 10