If you want to know how many values match in both the dictionaries, you should have said that 🙂
Maybe something like this:
shared_items = {k: x[k] for k in x if k in y and x[k] == y[k]}
print(len(shared_items))
More Related Contents:
- Comparing Python dictionaries and nested dictionaries
- I don’t know how to display step 3 for this assignment
- Make a dictionary with duplicate keys in Python
- Access a particular field in arbitrarily nested JSON data [duplicate]
- How to use a dot “.” to access members of dictionary?
- How to implement an ordered, default dict?
- Why do my Tkinter widgets get stored as None? [duplicate]
- How can you print a variable name in python? [duplicate]
- Use cases for the ‘setdefault’ dict method
- How to efficiently compare two unordered lists (not sets)?
- How can I convert a dictionary into a list of tuples?
- Python variables as keys to dict
- How do I check that multiple keys are in a dict in a single pass?
- How do I print the key-value pairs of a dictionary in python
- How can I get dict from sqlite query?
- How to find the min/max value of a common key in a list of dicts?
- Python Dictionary to CSV
- How to use dot notation for dict in python?
- top values from dictionary
- Updating a dictionary in python
- can you write a str.replace() using dictionary values in Python?
- A python class that acts like dict
- Find dictionary keys with duplicate values
- How can I get dictionary key as variable directly in Python (not by searching from value)?
- What are dict_keys, dict_items and dict_values?
- Using Python class as a data container [closed]
- How can I convert string values from a dictionary, into int/float datatypes?
- How to type hint a dictionary with values of different types
- sorting list of nested dictionaries in python
- How to convert only numbers in a mixed list into float