(1) A snippet that takes a dictionary and uppercases every value in the dictionary and sets that value back into the dictionary at the same key e.g.
Given:
d = {'a': ['amber', 'ash'], 'b': ['bart', 'betty']}
Result:
{'a': ['AMBER', 'ASH'], 'b': ['BART', 'BETTY']}
(2) Why datatype SET
does not return TRUE
element when printed?
Eg.
{'hi', 1, True}
returns only {'hi', 1}
For (1) I am using something like this:
d = {'a': ['amber', 'ash'], 'b': ['bart', 'betty']}
d.update((k, v.upper()) for k, v in d.items())
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…