Python TypeError:inputNames()不接受任何参数(给定2个)

Python TypeError:inputNames()不接受任何参数(给定2个),python,arguments,Python,Arguments,初学者程序员在这里,并试图完成一项任务。第19行返回错误:TypeError:inputNames()不接受任何参数(给定2个)。第19行:playerOne,playerTwo=输入名称(playerOne,playerTwo)。这条线路是我的教授提供的,我不知道如何使它工作。任何帮助都将不胜感激 函数inputNames定义为不带参数的函数,但在方法列表中向其传递两个变量: 以下是您如何定义它的: #Lab 7-3 The Dice Game #add libraries needed im

初学者程序员在这里,并试图完成一项任务。第19行返回错误:TypeError:inputNames()不接受任何参数(给定2个)。第19行:playerOne,playerTwo=输入名称(playerOne,playerTwo)。这条线路是我的教授提供的,我不知道如何使它工作。任何帮助都将不胜感激

函数inputNames定义为不带参数的函数,但在方法列表中向其传递两个变量:

以下是您如何定义它的:

#Lab 7-3 The Dice Game
#add libraries needed
import random

#the main function
def main():
    print

    #initiliaze variables
    endProgram = 'no'
    playerOne = 'NO NAME'
    playerTwo = 'NO NAME'

    #call to inputNames
    playerOne, playerTwo = inputNames(playerOne, playerTwo)

    #while loop to run program again
    while endProgram == 'no':
        winnersName = 'NO NAME'
        p1number = 0
        p2number = 0

        #initiliaze variables

        #call to rollDice
        winnerName = rollDice(playerOne, playerTwo, winnerName)

        #call to displayInfo
        winnerName = displayInfo (winnerName)

        endProgram = input('Do you want to end program?(Enter yes or no): ')

#this function gets players names
def inputNames():
    inputNames = string('Enter your names: ')
    return playerOne, playerTwo    

#this function will get the random values
def rollDice():
    p1number = random.randint(1,6)
    p2number = random.randint(1,6)
    if p1number >= p2number:
        winnerName = playerOne
    if p1number == p2numer:
        winnerName = 'TIE'
    elif winnerName == playerTwo:
        return winnerName

#this function displays the winner
def displayInfo():
    print ('The winner is: ', winnerName)


#calls main
main()
你是这样称呼它的:

def inputNames():
    inputNames = string('Enter your names: ')
    return playerOne, playerTwo  
你真正想要的是这个函数返回玩家一和玩家二的名字。因此,上面的一行应该是:

playerOne, playerTwo = inputNames(playerOne, playerTwo)
函数必须在本地收集这两个名称并返回它们,可能是这样的:

playerOne, playerTwo = inputNames()

如果是你的教授给你的。。。也许这是一个提示,你应该能够修复。也许这就是任务。。。
def inputNames():
    p1 = str(raw_input("Enter the name for player one: "))
    p2 = str(raw_input("Enter the name for player two: "))
    return p1, p2