[Tutor] Help with Python

C Smith illusiontechniques at gmail.com
Sun May 11 09:58:19 CEST 2014


Hey Glen, include the error you are getting. It will make answering
your question easier. How are you running this program, in an IDE?

On Sat, May 10, 2014 at 11:16 PM, Glen Chan <gchan401 at msn.com> wrote:
> 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()
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list