https://www.codecademy.com/courses/learn-python-3/lessons/python-functions-dictionaries-cc/exercises/frequency-count - challenge 8 frequency count
Hey everyone, hope you’re living the dream!
Basically, I understand 99% of the code I’ve written here, but there are some crucial bits I don’t.
def frequency_dictionary(words): seen = set() seen_add = seen.add frequency = [words.count(word) for word in words if not (word in seen or seen_add(word)) ] return dict(zip(seen, frequency))
I pretty much made all this code by myself, the two portions I researched online to incorporate are:
seen_add = seen.add
...if not (word in seen or seen_add(word))]
I’ve played about and know without these bits my code breaks. I pretty much can understand the if condition. Just don’t really know what
seen.add is doing.
Cheers in advanced