![](/img/trans.png)
[英]I want to make a table in mysql using python and i get this error but i have data base named sam what should i do
[英]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():
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)
在“print(String_Num)”之后仅添加一行
print(sum(map(int, String_Num.split())))
我不得不使用谷歌翻译,但看起来你正在尝试对输入的字母求和。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.