Python | Concatenate two dictionaries into one

In this post, we will learn about how to concatenate two dictionaries into one in python.

Two dictionaries d1 and d2 are concatenated.

d1 = {'ramesh': 400, 'rahul':655,'rohit':600,'ritu':750}
d2 = {'riya':200,'ritika':450,'ruhani':800}
d1.update(d2)
print(d1)
Output:
{'ramesh': 400, 'rahul': 655, 'rohit': 600, 'ritu': 750, 'riya': 200, 'ritika': 450, 'ruhani': 800}

Happy Coding!

Follow us on Instagram @programmersdoor

Join us on Telegram @programmersdoor


Please write comments if you find any bug in the above code/algorithm, or find other ways to solve the same problem.

Follow Programmers Door for more.

#blog #interview #placement #learn #computer #science

        Contact Us

programmersdoor@gmail.com

  • LinkedIn
  • Facebook
  • Instagram

©2023 by Programmers Door