#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()
初学者程序员在这里并试图完成一项任务。第 19 行返回错误:TypeError: inputNames() 不接受任何参数(给定 2)。第 19 行:playerOne, playerTwo = inputNames(playerOne, playerTwo)。这条线是我的教授提供的,我不知道如何让它工作。任何帮助将不胜感激!