We say a word is balanced if all its letters have the same number of occurrences. For example, the word Caucasus contains four pairs of letters and the word SCINTILLESCENT contains seven pairs of letters.
Write a function occurrences that takes a string $$s$$ (str). The function must return a dictionary (dict) that maps each letter (str) in $$s$$ onto the number of occurrences (int) of that letter in $$s$$. All characters in $$s$$ that are no letter must be ignored. In counting the number of occurrences of a letter, no distinction must be made between uppercase and lowercase letters. The returned dictionary must use lowercase letters as its keys.
Write a function balanced that takes a string $$s$$. The function must return a Boolean value (bool) that indicates whether each letter occurs a fixed number of times $$n$$ in $$s$$, with $$n \geq 2$$. Counting the number of occurrences of the letters in $$s$$ must be done in the same way as in the function occurrences.
>>> occurrences('Caucasus')
{'a': 2, 'c': 2, 'u': 2, 's': 2}
>>> occurrences('teammate')
{'a': 2, 'm': 2, 'e': 2, 't': 2}
>>> occurrences('SCINTILLESCENT')
{'c': 2, 'e': 2, 'i': 2, 'l': 2, 'n': 2, 's': 2, 't': 2}
>>> occurrences('chachacha')
{'a': 3, 'h': 3, 'c': 3}
>>> occurrences('blahblahblahblah')
{'a': 4, 'h': 4, 'b': 4, 'l': 4}
>>> occurrences('intestine')
{'i': 2, 's': 1, 'e': 2, 't': 2, 'n': 2}
>>> balanced('Caucasus')
True
>>> balanced('teammate')
True
>>> balanced('SCINTILLESCENT')
True
>>> balanced('lysosome')
False
>>> balanced('intestines')
True
>>> balanced('mesosome')
True