Created
July 29, 2021 14:27
-
-
Save terashim/6f664e9a235d906f8f360bde90c4a553 to your computer and use it in GitHub Desktop.
dict にキーと値を追加する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = {"a": 1} | |
{**x, "b": 10} | |
# {'a': 1, 'b': 10} | |
lst = [{"a": 1}, {"a": 2}] | |
list(map(lambda x: {**x, "b": 10}, lst)) | |
# [{'a': 1, 'b': 10}, {'a': 2, 'b': 10}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment