Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python merge two dictionaries

# Python 3.9
z = x | y

# Python 3.5
z = {**x, **y}

# Python <= 3.4
def merge_two_dicts(x, y):
    z = x.copy()   # start with keys and values of x
    z.update(y)    # modifies z with keys and values of y
    return z

z = merge_two_dicts(x, y)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Python #merge #dictionaries
ADD COMMENT
Topic
Name
3+2 =