[Tutor] Help with Python

Glen Chan gchan401 at msn.com
Sun May 11 05:16:53 CEST 2014


Hello, I am a student trying to figure out Python. I am getting errors that I don't know how to fix. What do you do after you get the error message and something is highlighted? Does that have to be deleted? Anyway, here is what I mean...
 
 
#>>> The Dice Game
#add libraries needed
import random
#the main function
def main():
    print
    #initialize variables
    playerOne = 'No Name'
    playerTwo = 'No Name'
    
    #call to inputNames
    playerOne, playerTwo = inputNames(playerOne, playerTwo)
    #while loop to run program again
    while endProgram == 'no':
        #initialize variables
     winnersName = 'NO NAME'
     p1number = 0
     p2number = 0
        #call to rollDice
     winnerName = rollDice(p1number, p2number, playerOne, playerTwo, winnerName)

        #call to displayInfo
     winnerName
        endProgram = raw_input('Do you want to end program? (Enter yes or no): ')
        
        
        
#this function gets the players names
def inputNames(playerOne, playerTwo):
    playerOne = raw_input("Enter Name")
    playerTwo = raw_input("Enter Name")                       
 
    return playerOne, playerTwo
#this function will get the random values
def rollDice(p1numer, p2numer, playerOne, playerTwo, winnerName):
 p1number = random.randint(1, 6)
 p1number = random.randint(1, 6)
 
#this function displays the winner
 
if p1number == p2number:
        winnerName = "TIE"
    elif p1number > p2number:
        winnerName = playerOne
    else:
        winnerName = playerTwo
    return winnerName

# calls main
main()
 
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140510/49588d99/attachment.html>


More information about the Tutor mailing list