我在python上制作代码,但它显示了一个星号,其中数字在单元格上,我尝试制作一个打印程序,看看它是否是代码,但它仍然无法正常工作。请帮忙,这是代码。
Items = ""
Total = 0
def adding_report(report):
while True:
X = input("please input integer to add or Q to quit")
if X.isdigit() == "True":
X = int(X)
Total = Total + X
if report == "A":
Items = Items + X
elif X == "Q":
print("Your result is")
if report == "A":
print("Items")
print(Items)
print("total")
print(Total)
break
else:
print("invalid input.")
adding_report("T")
答案 0 :(得分:2)
你陷入无限循环。
此外,您无法与字符串 "True"
进行比较,而只能与True
进行比较:
if X.isdigit() == True:
而不是:
if X.isdigit() == "True":
您也可以完全跳过与True
的比较
if X.isdigit():