Python Dictionary to sum ASCII values

sent = "hi people of the world"
words = sent.split(" ")

result = {}

# Calculate sum of ascii values for every word
for word in words:
    result[word] = sum(map(ord,word))

totalSum = 0
# Create an array with ASCII sum of words using the dict
sumForSentence = [result[word] for word in words]

print ('Sum of ASCII values:')
print (' '.join(map(str, sumForSentence)))

print ('Total of all ASCII values in sentence: ',sum(sumForSentence))


Learn More :