Functions: Fundamentals Practice Problems p.13 Anagrams

Hello, Community!

In Line 28 of the solution:
Why is c not in freq2 necessary?
Is there any situation in which freq1[c] != freq2[c] on its own is not sufficient?

https://app.dataquest.io/m/1012/functions%3A-fundamentals-practice-problems/13/anagrams

Both serve a different purpose.

c not in freq2 checks if the key, c, is in freq2 or not.

freq1[c] != freq2[c] checks if the values corresponding to the key, c, in both are the same or not. This also implies that c is a key in both the dictionaries because otherwise, on its own, this would throw an error. That’s why c not in freq2 is needed.