+ 1
What is meaning of this- a= { 0:1,1:2} _sum =0 for b in a : _sum+=b
2 Antworten
+ 6
This is a a quiz question IIRC.
Here the "b"s are the keys if the dictionary. This code essentially finds the sum of the keys.
+ 4
a is a dictionary where 0 is mapped to 1 and 1 is mapped to 2
for b in a iterates through all keys (0,1)
The loop counts their sum