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

Question:

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():
    if(val.isdigit()):
       print("Entschuldige, der Vorgang konnte nicht abgeschlossen werden!")
       bool = True
       break
    for key, value in dict.items():
        if(val == value):
            String_Num += str(key+1)
            # For spaces
            String_Num += " "

if (not bool):
    print(String_Num)
Asked By: Wilhelm Richter

||

Answers:

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.

Answered By: iohans
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.