I was wondering if any of you could look at my code and tell me what I am missing here. Basically, it takes user input for their names (playerOne and playerTwo). It is supposed to pick the larger number from the random choice and display that user's name as the winner. It is displaying the random numbers chosen, but not the winner's name.
#Add libraries needed
import random
#The main function
def main():
print
#Initialize 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":
winnerName ='NO NAME'
p1number = 0
p2number = 0
#Initialize variables
#Call to rollDice
winnerName = rollDice(p1number, p2number, playerOne, playerTwo, winnerName)
#Call to displayInfo
displayInfo(winnerName)
endProgram = raw_input('Do you want to end the program? (Enter yes or no): ')
#This function gets the players names
def inputNames(playerOne, playerTwo):
playerOne = raw_input('Enter P1 name: ')
playerTwo = raw_input('Enter P2 name: ')
return playerOne, playerTwo
#This function will get the random values
def rollDice(p1number, p2number, playerOne, playerTwo, winnerName):
p1number = random.randint(1,6)
p2number = random.randint(1,6)
return p1number, p2number
if p1number == p2number:
winnerName = "TIE"
elif p1number > p2number:
winnerName = playerOne
elif p2number > p1number:
winnerName = playerTwo
return winnerName
#This function displays the winner
def displayInfo(winnerName):
print winnerName
#Calls main
main()
displayInfo(winnerName)instead ofprint winnerNamedirectly? You don't gain anything by wrapping that in a function.