Question: I have two dictionaries as follows:

`D1={'a':1,'b':2,'c':3}`

and 

`D2={'b':2,'c':3,'d':1}`

I want to merge these two dictionaries and the result should be as follows:

`D3={'a':1,'b':2,'c':3,'b':2,'c':3,'d':1}`

how can I achieve this in python?

Answer: 
You may want to try:

```
D3 = {}
D3.update(D1)
D3.update(D2)

```

Here, we're creating an empty dictionary `D3` first, then update it from the two other dictionaries.

Note that you need to be careful with the order of the updates: if `D2` shares some keys with `D1`, the code above will overwrite the corresponding entries of `D1` with those of `D2`.

Note as well that the keys will **not** be repeated. The example you give `D3={a:1,b:2,c:3,b:2,c:3,d:1}` is not a valid dictionary.
```
In [3]: D1={'a':1,'b':2,'c':3}

In [4]: D2={'b':2,'c':3,'d':1}

In [5]: D1.update(D2)

In [6]: D1
Out[6]: {'a': 1, 'b': 2, 'c': 3, 'd': 1}

```

**Update**

Alternative solutions

```
In [9]: D3=D1.copy()

In [10]: D3.update(D2)

In [11]: D3
Out[11]: {'a': 1, 'b': 2, 'c': 3, 'd': 1}

In [12]: D4=dict(D1, **D2)

```

or

```
In [13]: D4
Out[13]: {'a': 1, 'b': 2, 'c': 3, 'd': 1}

```

or

```
In [16]: D5 = dict(D1.items() + D2.items())

In [17]: D5
Out[17]: {'a': 1, 'b': 2, 'c': 3, 'd': 1}

```