What do i have to do if i want to Sum my result using Python?

import string
dict = {}
bool = False
user_string = input("Bitte gebe hier die Buchstaben ein, welche du Summieren möchtest:")
String_Num = ""

for i, char in enumerate(string.ascii_lowercase):
    dict[i] = char # This is dictinoary.

for val in user_string.lower():
       print("Entschuldige, der Vorgang konnte nicht abgeschlossen werden!")
       bool = True
    for key, value in dict.items():
        if(val == value):
            String_Num += str(key+1)
            # For spaces
            String_Num += " "

if (not bool):

>Solution :

Add just one line after the ‘print(String_Num)’

print(sum(map(int, String_Num.split())))

I had to use Google translate, but it looks like you are trying to sum the letters that are inputted.

Leave a Reply Cancel reply