我正在嘗試為一個簡單的游戲編寫代碼。游戲的設計很好。但是我很難在原始輸入函數中包含一個變量以及文本。任何幫助,將不勝感激。這是代碼while True: n=int(input("How many marbles to start with? ")) #Exercise 2.4 if (n>=1) and ((n%1)==0): break else: print("enter a positive integer")while n>0: p2=int(input("Player #1, there are",n, "marbles left. How many marbles will you take? ")) if (p2 not in (1,2,3)) or (p2>n): print("not a proper input") else: n=n-p2 if n==0: print("Player #1, you took the last marble and have won! ") else: while True: p1=int(input("Player #2, there are",n, "marbles left. How many marbles will you take? ")) if (p1 not in (1,2,3)) or (p1>n): print("not a proper input") else: n=n-p1 if n==0: print("Player #2, you took the last marble and have won! ") break這是我收到的錯誤消息TypeError Traceback (most recent call last)<ipython-input-13-d507a539ca61> in <module> 6 print("enter a positive integer") 7 while n>0:----> 8 p2=int(input("Player #1, there are",(n), "marbles left. How many marbles will you take? ")) 9 if (p2 not in (1,2,3)) or (p2>n): 10 print("not a proper input")TypeError: raw_input() takes from 1 to 2 positional arguments but 4 were given
添加回答
舉報
0/150
提交
取消