sample = "i am feeling good"
output = {}
output["word"] = len(sample.split())
output["chars"] = len(list(sample))
for elem in sample.split():
output[elem] = len(list(elem))
print(output)
output:
{'word': 4, 'chars': 17, 'i': 1, 'am': 2, 'feeling': 7, 'good': 4}
solved A dictionary that returns number of word and each word’s lenght Python