A key in a dictionary will not be repeated, and will be overwritten when the same key is assigned a second time.
Back to code: d={x:y for x in [1,3,5] for y in [2,4,6]}
x traverses once, y traverses 3 times,
-
< li > when x = 1, the change of d: < br / > d = {1} < br / > d = {and} < br / > d = {for} < / li > < li > when x = 3, the variation regularity of d: < br / > d = {1, 2} < br / > d = {1:4, 3:4} < br / > d = {} and set 1:6, < / li > < li > when x = 5, the variation regularity of d: < br / > d = {1, 3:2, 5-2} < br / > d = {1:4, 3:4, five} < br / > d = {1:6, set, but} < br / > so the end result is: {12 1:6, 3:6,} < blockquote >
If it helps, please click to accept ~