Apr-23-2021, 08:15 AM
(Apr-22-2021, 04:52 PM)Anldra12 Wrote: for word, count in freq.items():You are iterating over the dictionary "freq". But then you delete an item from the dictionary. So Python does not know how to continue with the iteration. It is not allowed to change a dictionary (or list or ...) while iterating over it.
if is_cap(word) and word.lower() in freq:
count = freq[word]
freq[word.lower()] += count
del freq[word]