Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

My dice aren't rolling, can someone tell me why?

Here's the code, it is supposed to take in two names and randomly roll two series of dice, once for each player. It is taking the names as input but it's not rolling the dice and giving the winners.

#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':
        winnersName = 'NO NAME'
        p1number = 0
        p2number = 0 

        #initialize variables
        p1number = 0
        p2number = 0
        winnersName = 'NO NAME'


        #call to rollDice
        winnersName = rollDice(p1number, p2number, playerOne, playerTwo, winnersName)
        #call to displayInfo
        displayInfo = winnersName


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


#this function gets the players names
def inputNames(playerOne, playerTwo):
    playerOne = input("Enter your name, player one: ")
    playerTwo = input("Enter your name, player two: ")
    return playerOne, playerTwo


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


#this function displays the winner
def displayInfo(winnersName):
    print("The winner is: ", winnersName)


# calls main
main()