I want to apply a function to all values in dict and store that in a separate dict. I am just trying to see how I can play with python and want to see how I can rewrite something like this
for i in d:
d2[i] = f(d[i])
to something like
d2[i] = f(d[i]) for i in d
The first way of writing it is of course fine, but I am trying to figure how python syntax can be changed
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…