words = sentences.split()
dictionary = {}
for i in words:
    if len(i) in dictionary:
        dictionary[len(i)] += 1
else:
    dictionary[len(i)] = 1
print(dictionary)
How to build a dictionary of string lengths using a for loop?