We can use the identity operators in or not in to check whether a key exists in the dictionary.
So let's check if the key is to exists in dictionary dict 1.
Then execute.
So it has returned the Boolean value to use the identity operator not in dict 1.
It should return finds the key to exists in the dictionary dict 1
we can use the comparison operators to check whether 2 dictionaries contains the same items.
So let's see if the dictionaries dict 1 and Dick do have the same items and not this is false.
These are the items in to let us also verify the not equal to operator not equal to the 2.
So this is true because dict 1 and 2 have different items
looping items in the dictionary.
A for loop can be used to iterate over the elements in the dictionary.
So here we have the dictionary dict.
1 and let us now display the keys present in this dictionary.
So using the keys method so the output is a list of keys indicate one now using a for loop.
I want to display the keys existing in the dictionary dict 1.
So for that let's put this statement like this.
For every element in dict one dart keys.
So for every element in this list I want to print the element that is sticky.
So let us now execute this after you've executed this line.
You have all the keys displayed in the output.
Similarly we can display the while using dict one by either rating through did the elements in the dictionary
dict 1 using a for loop.
So for that let's first display the values in dictionary 1 using the values method.
So here we have a list of these values in the dictionary dict 1.
Now using the for loop lets I did it over these elements dict 1 dot so far y you indicate 1 dot 1 use
in devalue execute this and now you have all the values displayed using the for loop.
You can also display the key value pairs in the dictionary using the for loop.
So for that default loop statement should be fought.
Item In dict 1 dot items please don't worry too much about code syntax.
We will have a separate tutorial on for loop in the upcoming sessions for now.
Just follow along so for item in dict one dot items but in item and this fourth statement would return
a tuples of the key value pairs.
And this is a boat item rating or dictionaries using for loop.