---
title: "Discussion on \"The Best Way to Compare Two Dictionaries in Python\" | Hashnode"
description: "Discussion on \"The Best Way to Compare Two Dictionaries in Python\". Learn how to check if two dictionaries are equal, assert for equality in unit tests, compare keys and values, take their dict diff, and more!"
url: "https://hashnode.com/posts/the-best-way-to-compare-two-dictionaries-in-python/5f8aa6e9d7dc0b17a97a2acc"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [The Best Way to Compare Two Dictionaries in Python](https://miguendes.me/the-best-way-to-compare-two-dictionaries-in-python?utm_source=hashnode&utm_medium=feed)

Learn how to check if two dictionaries are equal, assert for equality in unit tests, compare keys and values, take their dict diff, and more!

Oct 17, 2020 · 8 min read · miguendes.me  
Updated Jan 31, 2022  
Read the article

-   [#python](https://hashnode.com/tag/python)
-   [#beginners](https://hashnode.com/tag/beginners)
-   [#tutorial](https://hashnode.com/tag/tutorial)

## Written by

[Miguel Brito](https://hashnode.com/@miguendes)

@miguendes · London, UK

  
[View profile](https://hashnode.com/@miguendes)

Machine Learning Software Engineer - Hobbyst Technical Writer - Interested in Software Testing, Best Practices, Scalability, and Python.

AI Software Engineer based in London, UK with 6+ years of professional experience developing and releasing software in different programming languages - Hobbyist Technical Writer - Interested in Software Testing, Best Practices, Scalability, Machine Learning/AI, and Python.

## Responses 3

Markdown supported · ⌘↵ to post

[Ayushi Rawat](https://hashnode.com/@ayushi7rawat)

[Oct 22, 2020](https://hashnode.com/posts/the-best-way-to-compare-two-dictionaries-in-python/5f8aa6e9d7dc0b17a97a2acc/comment/5f91ba82c626a0545fb61463)

Very well explained!

[Miguel Brito](https://hashnode.com/@miguendes)

[Oct 22, 2020](https://hashnode.com/posts/the-best-way-to-compare-two-dictionaries-in-python/5f8aa6e9d7dc0b17a97a2acc/comment/5f91ba82c626a0545fb61463#reply-5f91c936c626a0545fb61569)

Thanks @ayushi7rawat, glad you liked it!

[Edidiong Asikpo (Didi)](https://hashnode.com/@didicodes)

[Oct 19, 2020](https://hashnode.com/posts/the-best-way-to-compare-two-dictionaries-in-python/5f8aa6e9d7dc0b17a97a2acc/comment/5f8d9686d58df13bb2917450)

This is a fantastic article [Miguel Brito](https://hashnode.com/@miguendes). Thanks for sharing.

[Miguel Brito](https://hashnode.com/@miguendes)

[Oct 22, 2020](https://hashnode.com/posts/the-best-way-to-compare-two-dictionaries-in-python/5f8aa6e9d7dc0b17a97a2acc/comment/5f8d9686d58df13bb2917450#reply-5f91c8ccc626a0545fb61553)

Thanks @Didicodes!

[Paula Maranhão](https://hashnode.com/@pmaranhaor)

[Oct 17, 2020](https://hashnode.com/posts/the-best-way-to-compare-two-dictionaries-in-python/5f8aa6e9d7dc0b17a97a2acc/comment/5f8b60c06eb39417ce5e6248)

I could use this, even being so newbie with Python. Keep trying to help different levels of learning! Thanks.

[Miguel Brito](https://hashnode.com/@miguendes)

[Oct 22, 2020](https://hashnode.com/posts/the-best-way-to-compare-two-dictionaries-in-python/5f8aa6e9d7dc0b17a97a2acc/comment/5f8b60c06eb39417ce5e6248#reply-5f91c8ecc626a0545fb6155b)

You're welcome, I'm glad to hear that!
