繁体   English   中英

读取用户输入会导致“ TypeError:int()最多接受2个参数(给定3个)”

[英]Reading user input causes “TypeError: int() takes at most 2 arguments (3 given)”

我正在做一个游戏,每位玩家每回合可赢1-3个筹码,最后一个筹码的人获胜。 在要求玩家选择一定数量的筹码的部分,我收到一条错误消息:

Traceback (most recent call last):
  File "F:\DOwnloads\okay (1).py", line 56, in <module>
    temp = input(int ("there are", chips,"chips. how many chips does player one want to take"))
TypeError: int() takes at most 2 arguments (3 given)

这是代码:

chips  = 21
MAXCHIPS= 3
MINCHIPS= 1

playerOne = " "
playerTwo = " "

score1 = 0
TIE = "it was a tie"
score2 = 0
INTRO = "do you know how to play takeaways? please enter either yes or no"
RULES = "you each take turns to remove 1-3 chips from a pileof 21. whoever      takes the last chip from the pile wins the round"



while(True):
        instructions=input(INTRO)
        if ((instructions == "yes") or (instructions == "no")):
        if (instructions == "no"):
               print (RULES)
              break
            elif (instructions == "yes"):
                break

while( True ):
        temp=input("what is player ones name? please enter a one word name")

        if (temp.isalpha()) :
                temp=playerOne
                break

while( True ):
        temp=input("what is player twos name? please enter a one word name")
        if (temp.isalpha()) :
             temp=playerTwo
            break
while( True ):
    game = input("How many gammes do  you want to play?")
    if( game.isdigit() ):
        game = int(game)
    if( game > 0 )and (game < 10):
        break


while( True):
    chips = int(chips)
    temp = input(int ("there are", chips,"chips. how many chips does player one want to take"))
    if (temp.isdigit() ):
            temp = int(temp)
            chips=-temp
            break

您需要int(input("input string"))时具有input(int("input string")) int(input("input string"))

更改此行:

temp = input(int ("there are", chips,"chips. how many chips does player one want to take"))

对此:

temp = int(input("there are", chips,"chips. how many chips does player one want to take"))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM