2017-10-15 2411 views
0

我在python上編寫代碼,但是它顯示星號,數字在單元格上,我試着讓打印程序看看它是否是代碼,但它仍然無效。請幫忙,這是代碼。jupyter上的星號(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") 
+2

什麼是錯誤?您的問題是什麼? – eyllanesc

回答

2

你被困在一個無限循環中。 此外,你不能比較的"True",但只寧可True

if X.isdigit() == True: 

相反的:

if X.isdigit() == "True": 

您也可以跳過比較True

if X.isdigit():