I made a function that outputs the sum of the value of each letter in a word. For example if I input hello my function would output 52.
def words_to_marks(s):
import string
values = {} # dictionary to store value of each alphabet
values_of_words = [] # to store final value of words
for index, letters in enumerate(string.ascii_lowercase, 1): # creates the dictionary
values[letters] = index
final = [] # stores value of each number before adding
for letter in s:
letter_lower = letter.lower
final.append(values[letter]) # appends the value of each letter into the list
values_of_words.append(sum(final)) # sums all the values in the list
submit = str(values_of_words) # converts into string so I can remove the brackets around the list
return submit[1:-1]
test = words_to_marks("friends")
print(test)
I would really appreciate it if someone could point me to the right direction for how I should condense or improve my code.