Python 3.x Cannot figure out Pickling











up vote
0
down vote

favorite












This is a homework thing. I am in the online section of an intro Python course. We are supposed to create a program for our final that allows the user to select if they are a new or returning player. If they are a new player, a new .rps file should be created through pickle that stores the users win/loss/tie statistics. If the player is returning, they should be able to load their "name".rps file so that all of their statistics are loaded into the proper places.



I am having a horrible time using pickle. I have put probably 30 hours into this (hard to believe looking at the horrible code). I really need help with finding a way to use pickle to create and access the files generated by the program. I think I can fix any other problems with the program. It has just made me feel incredibly dumb. The TA's for the course haven't responded to emails and the professor replied with an "email the TA's" answer. I'm lost and alone.



import random
import pickle

tie = 0
pcWon = 0
playerWon = 0
game_round = (tie + playerWon + pcWon) + 1

# creates the main function used to start the program
def main():

welcomemenu()
playGame = True
global playGame
while playGame:
playGame = play()
displayScoreBoard()
prompt = input("Press enter to exit")


# creates the welcomemenu function which displays start screen and requests user input. Opens .rps file for returning players.
def welcomemenu():
menuselect = int(input("Welcome to Rock, Paper, Scissors! nn1. Start New Game n2. Load Game n3. Quit nnEnter Choice:"))
print("")
global name
if menuselect == 1:
name = input("What is your name? ")
global name
print("Hello ", name, ".",sep="")
print("Let's play!")
playerFile = {name:"", playerWon: "", pcWon:"", tie:""}
global playerFile
global playerFileOpen

newPlayer(name)
elif menuselect == 2:

name = input("What is your name? ")
global name
print("Welcome back ", name, ".", " Let's play!", sep="")
loadPlayer(name)

elif menuselect == 3:
exit()
return menuselect


def loadPlayer(name):
with open (name+".rsp", "r+") as playerFile:
#playerFile = {name:"", playerWon: "", pcWon:"", tie:""}
pickle.dump(playerFile, name, protocol=pickle.HIGHEST_PROTOCOL)
def newPlayer(name):
with open (name+".rsp", "r+") as playerFile:
playerFile = {name:"", playerWon: "", pcWon:"", tie:""}
pickle.dump(playerFile, name, protocol=pickle.HIGHEST_PROTOCOL)

# creates the play function which calls the playerMenu function to determine player selection of RPS. Compares against the computer RPS selection
def play():
playerChoice = int(playerMenu())
if playerChoice == 4:
return 0
else:
pcChoice = pcGenerate()
outcome = evaluateGame(playerChoice, pcChoice)
updateScoreBoard(outcome)
return 1


# creates the player menu and asks for user selection of their RPS value.
def playerMenu():
print("Round ", (tie+playerWon+pcWon), "nn1. Rockn2. Papern3. Scissorsnn")
menuSelect = input("What will it be? ")
while not validateInput(menuSelect):
invalidChoice(menuSelect)
menuSelect = input("Invalid option.n1. Rockn2. Papern3. Scissorsn : ")

return menuSelect


# creates validateInput function for menuSelection function and checks if user input was valid
def validateInput(menuSelection):
if menuSelection == "1" or menuSelection == "2" or menuSelection == "3":
return True
else:
return False


# creates pcGenerate function to have the pc generate a value from 1-3 to play against player value
def pcGenerate():
pcChoice = random.randint(1,3)
return pcChoice


# creates evaulateGame function to check the players input against the computer. Prints results
def evaluateGame(playerChoice, pcChoice):
if playerChoice == 1:
if pcChoice == 1:
#tie
print("You chose Rock. The computer chose rock. You tie!")
return 0
elif pcChoice == 2:
#paper covers rock - pc won
print("You chose Rock. The computer chose paper. You lose!")
return -1
else:
#rock breaks scissors - player won
print("You chose Rock. The computer chose scissors. You win!")
return 1
elif playerChoice == 2:
if pcChoice == 1:
#paper covers rock - player won
print("You chose paper. The computer chose rock. You win!")
return 1
elif pcChoice == 2:
#tie
print("You chose paper. The computer chose paper. You tie!")
return 0
else:
#scissors cut paper - pc won
print("You chose paper. The computer chose scissors. You lose!")
return -1
else: #plyer choice defaults to 3
if pcChoice == 1:
#rock breaks scissors - pc won
print("You chose scissors. The computer chose rock. You lose.")
return -1
elif pcChoice == 2:
#scissors cut paper - player won
print("You chose scissors. The computer chose paper. You win!")
return 1
else: #pc defaults to scissors
#tie
print("You chose scissors. The computer chose scissors. You tie!")
return 0

# creates endGame function to create a menu for a post-round user input request
def endGame():
endChoice = int(input("What would you like to do? nn1. Play Againn2. View Stasticsn3. QuitnnEnter choice:"))
if endChoice == 1:
playerMenu()
elif endChoice == 2:
displayScoreBoard()
else:
pickle.dump(new_player, np_open)
playerFileOpen.close()
player_file.close()
exit()


# creats updateScoreBoard function that keeps track of wins, ties, and losses. Updates the dictionary entries with appropriate values
def updateScoreBoard(gameStatus):
global tie, playerWon, pcWon
if gameStatus == 0:
tie +=1
playerFile.update(tie +1)
endGame()
elif gameStatus == 1:
playerWon += 1
playerFile.update(playerWon +1)
endGame()
else:
pcWon += 1
playerFileOpen.update(pcWon +1)
endGame()


# creates invalidChoice function for menuSelect function. informs user of an invalid choice
def invalidChoice(menuSelect):
print(menuSelect, "is not a valid option. Please use 1-3")


# creates displayScoreBoard function for statistics
def displayScoreBoard():
global tie, playerWon, pcWon
print(name, ", here are your game play statistics...")
print("Wins: ", playerWon)
print("Losses: ", pcWon)
print("Ties: ", tie)
if pcWon == 0:
print("Win/Loss Ratio: 1.00")
else:
print("Win/Loss Ration: ", "%.2f" %(playerWon/pcWon), )
print("Rounds:", tie + playerWon + pcWon)
endGame()
main()









share|improve this question







New contributor




beardybaldy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    up vote
    0
    down vote

    favorite












    This is a homework thing. I am in the online section of an intro Python course. We are supposed to create a program for our final that allows the user to select if they are a new or returning player. If they are a new player, a new .rps file should be created through pickle that stores the users win/loss/tie statistics. If the player is returning, they should be able to load their "name".rps file so that all of their statistics are loaded into the proper places.



    I am having a horrible time using pickle. I have put probably 30 hours into this (hard to believe looking at the horrible code). I really need help with finding a way to use pickle to create and access the files generated by the program. I think I can fix any other problems with the program. It has just made me feel incredibly dumb. The TA's for the course haven't responded to emails and the professor replied with an "email the TA's" answer. I'm lost and alone.



    import random
    import pickle

    tie = 0
    pcWon = 0
    playerWon = 0
    game_round = (tie + playerWon + pcWon) + 1

    # creates the main function used to start the program
    def main():

    welcomemenu()
    playGame = True
    global playGame
    while playGame:
    playGame = play()
    displayScoreBoard()
    prompt = input("Press enter to exit")


    # creates the welcomemenu function which displays start screen and requests user input. Opens .rps file for returning players.
    def welcomemenu():
    menuselect = int(input("Welcome to Rock, Paper, Scissors! nn1. Start New Game n2. Load Game n3. Quit nnEnter Choice:"))
    print("")
    global name
    if menuselect == 1:
    name = input("What is your name? ")
    global name
    print("Hello ", name, ".",sep="")
    print("Let's play!")
    playerFile = {name:"", playerWon: "", pcWon:"", tie:""}
    global playerFile
    global playerFileOpen

    newPlayer(name)
    elif menuselect == 2:

    name = input("What is your name? ")
    global name
    print("Welcome back ", name, ".", " Let's play!", sep="")
    loadPlayer(name)

    elif menuselect == 3:
    exit()
    return menuselect


    def loadPlayer(name):
    with open (name+".rsp", "r+") as playerFile:
    #playerFile = {name:"", playerWon: "", pcWon:"", tie:""}
    pickle.dump(playerFile, name, protocol=pickle.HIGHEST_PROTOCOL)
    def newPlayer(name):
    with open (name+".rsp", "r+") as playerFile:
    playerFile = {name:"", playerWon: "", pcWon:"", tie:""}
    pickle.dump(playerFile, name, protocol=pickle.HIGHEST_PROTOCOL)

    # creates the play function which calls the playerMenu function to determine player selection of RPS. Compares against the computer RPS selection
    def play():
    playerChoice = int(playerMenu())
    if playerChoice == 4:
    return 0
    else:
    pcChoice = pcGenerate()
    outcome = evaluateGame(playerChoice, pcChoice)
    updateScoreBoard(outcome)
    return 1


    # creates the player menu and asks for user selection of their RPS value.
    def playerMenu():
    print("Round ", (tie+playerWon+pcWon), "nn1. Rockn2. Papern3. Scissorsnn")
    menuSelect = input("What will it be? ")
    while not validateInput(menuSelect):
    invalidChoice(menuSelect)
    menuSelect = input("Invalid option.n1. Rockn2. Papern3. Scissorsn : ")

    return menuSelect


    # creates validateInput function for menuSelection function and checks if user input was valid
    def validateInput(menuSelection):
    if menuSelection == "1" or menuSelection == "2" or menuSelection == "3":
    return True
    else:
    return False


    # creates pcGenerate function to have the pc generate a value from 1-3 to play against player value
    def pcGenerate():
    pcChoice = random.randint(1,3)
    return pcChoice


    # creates evaulateGame function to check the players input against the computer. Prints results
    def evaluateGame(playerChoice, pcChoice):
    if playerChoice == 1:
    if pcChoice == 1:
    #tie
    print("You chose Rock. The computer chose rock. You tie!")
    return 0
    elif pcChoice == 2:
    #paper covers rock - pc won
    print("You chose Rock. The computer chose paper. You lose!")
    return -1
    else:
    #rock breaks scissors - player won
    print("You chose Rock. The computer chose scissors. You win!")
    return 1
    elif playerChoice == 2:
    if pcChoice == 1:
    #paper covers rock - player won
    print("You chose paper. The computer chose rock. You win!")
    return 1
    elif pcChoice == 2:
    #tie
    print("You chose paper. The computer chose paper. You tie!")
    return 0
    else:
    #scissors cut paper - pc won
    print("You chose paper. The computer chose scissors. You lose!")
    return -1
    else: #plyer choice defaults to 3
    if pcChoice == 1:
    #rock breaks scissors - pc won
    print("You chose scissors. The computer chose rock. You lose.")
    return -1
    elif pcChoice == 2:
    #scissors cut paper - player won
    print("You chose scissors. The computer chose paper. You win!")
    return 1
    else: #pc defaults to scissors
    #tie
    print("You chose scissors. The computer chose scissors. You tie!")
    return 0

    # creates endGame function to create a menu for a post-round user input request
    def endGame():
    endChoice = int(input("What would you like to do? nn1. Play Againn2. View Stasticsn3. QuitnnEnter choice:"))
    if endChoice == 1:
    playerMenu()
    elif endChoice == 2:
    displayScoreBoard()
    else:
    pickle.dump(new_player, np_open)
    playerFileOpen.close()
    player_file.close()
    exit()


    # creats updateScoreBoard function that keeps track of wins, ties, and losses. Updates the dictionary entries with appropriate values
    def updateScoreBoard(gameStatus):
    global tie, playerWon, pcWon
    if gameStatus == 0:
    tie +=1
    playerFile.update(tie +1)
    endGame()
    elif gameStatus == 1:
    playerWon += 1
    playerFile.update(playerWon +1)
    endGame()
    else:
    pcWon += 1
    playerFileOpen.update(pcWon +1)
    endGame()


    # creates invalidChoice function for menuSelect function. informs user of an invalid choice
    def invalidChoice(menuSelect):
    print(menuSelect, "is not a valid option. Please use 1-3")


    # creates displayScoreBoard function for statistics
    def displayScoreBoard():
    global tie, playerWon, pcWon
    print(name, ", here are your game play statistics...")
    print("Wins: ", playerWon)
    print("Losses: ", pcWon)
    print("Ties: ", tie)
    if pcWon == 0:
    print("Win/Loss Ratio: 1.00")
    else:
    print("Win/Loss Ration: ", "%.2f" %(playerWon/pcWon), )
    print("Rounds:", tie + playerWon + pcWon)
    endGame()
    main()









    share|improve this question







    New contributor




    beardybaldy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      This is a homework thing. I am in the online section of an intro Python course. We are supposed to create a program for our final that allows the user to select if they are a new or returning player. If they are a new player, a new .rps file should be created through pickle that stores the users win/loss/tie statistics. If the player is returning, they should be able to load their "name".rps file so that all of their statistics are loaded into the proper places.



      I am having a horrible time using pickle. I have put probably 30 hours into this (hard to believe looking at the horrible code). I really need help with finding a way to use pickle to create and access the files generated by the program. I think I can fix any other problems with the program. It has just made me feel incredibly dumb. The TA's for the course haven't responded to emails and the professor replied with an "email the TA's" answer. I'm lost and alone.



      import random
      import pickle

      tie = 0
      pcWon = 0
      playerWon = 0
      game_round = (tie + playerWon + pcWon) + 1

      # creates the main function used to start the program
      def main():

      welcomemenu()
      playGame = True
      global playGame
      while playGame:
      playGame = play()
      displayScoreBoard()
      prompt = input("Press enter to exit")


      # creates the welcomemenu function which displays start screen and requests user input. Opens .rps file for returning players.
      def welcomemenu():
      menuselect = int(input("Welcome to Rock, Paper, Scissors! nn1. Start New Game n2. Load Game n3. Quit nnEnter Choice:"))
      print("")
      global name
      if menuselect == 1:
      name = input("What is your name? ")
      global name
      print("Hello ", name, ".",sep="")
      print("Let's play!")
      playerFile = {name:"", playerWon: "", pcWon:"", tie:""}
      global playerFile
      global playerFileOpen

      newPlayer(name)
      elif menuselect == 2:

      name = input("What is your name? ")
      global name
      print("Welcome back ", name, ".", " Let's play!", sep="")
      loadPlayer(name)

      elif menuselect == 3:
      exit()
      return menuselect


      def loadPlayer(name):
      with open (name+".rsp", "r+") as playerFile:
      #playerFile = {name:"", playerWon: "", pcWon:"", tie:""}
      pickle.dump(playerFile, name, protocol=pickle.HIGHEST_PROTOCOL)
      def newPlayer(name):
      with open (name+".rsp", "r+") as playerFile:
      playerFile = {name:"", playerWon: "", pcWon:"", tie:""}
      pickle.dump(playerFile, name, protocol=pickle.HIGHEST_PROTOCOL)

      # creates the play function which calls the playerMenu function to determine player selection of RPS. Compares against the computer RPS selection
      def play():
      playerChoice = int(playerMenu())
      if playerChoice == 4:
      return 0
      else:
      pcChoice = pcGenerate()
      outcome = evaluateGame(playerChoice, pcChoice)
      updateScoreBoard(outcome)
      return 1


      # creates the player menu and asks for user selection of their RPS value.
      def playerMenu():
      print("Round ", (tie+playerWon+pcWon), "nn1. Rockn2. Papern3. Scissorsnn")
      menuSelect = input("What will it be? ")
      while not validateInput(menuSelect):
      invalidChoice(menuSelect)
      menuSelect = input("Invalid option.n1. Rockn2. Papern3. Scissorsn : ")

      return menuSelect


      # creates validateInput function for menuSelection function and checks if user input was valid
      def validateInput(menuSelection):
      if menuSelection == "1" or menuSelection == "2" or menuSelection == "3":
      return True
      else:
      return False


      # creates pcGenerate function to have the pc generate a value from 1-3 to play against player value
      def pcGenerate():
      pcChoice = random.randint(1,3)
      return pcChoice


      # creates evaulateGame function to check the players input against the computer. Prints results
      def evaluateGame(playerChoice, pcChoice):
      if playerChoice == 1:
      if pcChoice == 1:
      #tie
      print("You chose Rock. The computer chose rock. You tie!")
      return 0
      elif pcChoice == 2:
      #paper covers rock - pc won
      print("You chose Rock. The computer chose paper. You lose!")
      return -1
      else:
      #rock breaks scissors - player won
      print("You chose Rock. The computer chose scissors. You win!")
      return 1
      elif playerChoice == 2:
      if pcChoice == 1:
      #paper covers rock - player won
      print("You chose paper. The computer chose rock. You win!")
      return 1
      elif pcChoice == 2:
      #tie
      print("You chose paper. The computer chose paper. You tie!")
      return 0
      else:
      #scissors cut paper - pc won
      print("You chose paper. The computer chose scissors. You lose!")
      return -1
      else: #plyer choice defaults to 3
      if pcChoice == 1:
      #rock breaks scissors - pc won
      print("You chose scissors. The computer chose rock. You lose.")
      return -1
      elif pcChoice == 2:
      #scissors cut paper - player won
      print("You chose scissors. The computer chose paper. You win!")
      return 1
      else: #pc defaults to scissors
      #tie
      print("You chose scissors. The computer chose scissors. You tie!")
      return 0

      # creates endGame function to create a menu for a post-round user input request
      def endGame():
      endChoice = int(input("What would you like to do? nn1. Play Againn2. View Stasticsn3. QuitnnEnter choice:"))
      if endChoice == 1:
      playerMenu()
      elif endChoice == 2:
      displayScoreBoard()
      else:
      pickle.dump(new_player, np_open)
      playerFileOpen.close()
      player_file.close()
      exit()


      # creats updateScoreBoard function that keeps track of wins, ties, and losses. Updates the dictionary entries with appropriate values
      def updateScoreBoard(gameStatus):
      global tie, playerWon, pcWon
      if gameStatus == 0:
      tie +=1
      playerFile.update(tie +1)
      endGame()
      elif gameStatus == 1:
      playerWon += 1
      playerFile.update(playerWon +1)
      endGame()
      else:
      pcWon += 1
      playerFileOpen.update(pcWon +1)
      endGame()


      # creates invalidChoice function for menuSelect function. informs user of an invalid choice
      def invalidChoice(menuSelect):
      print(menuSelect, "is not a valid option. Please use 1-3")


      # creates displayScoreBoard function for statistics
      def displayScoreBoard():
      global tie, playerWon, pcWon
      print(name, ", here are your game play statistics...")
      print("Wins: ", playerWon)
      print("Losses: ", pcWon)
      print("Ties: ", tie)
      if pcWon == 0:
      print("Win/Loss Ratio: 1.00")
      else:
      print("Win/Loss Ration: ", "%.2f" %(playerWon/pcWon), )
      print("Rounds:", tie + playerWon + pcWon)
      endGame()
      main()









      share|improve this question







      New contributor




      beardybaldy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      This is a homework thing. I am in the online section of an intro Python course. We are supposed to create a program for our final that allows the user to select if they are a new or returning player. If they are a new player, a new .rps file should be created through pickle that stores the users win/loss/tie statistics. If the player is returning, they should be able to load their "name".rps file so that all of their statistics are loaded into the proper places.



      I am having a horrible time using pickle. I have put probably 30 hours into this (hard to believe looking at the horrible code). I really need help with finding a way to use pickle to create and access the files generated by the program. I think I can fix any other problems with the program. It has just made me feel incredibly dumb. The TA's for the course haven't responded to emails and the professor replied with an "email the TA's" answer. I'm lost and alone.



      import random
      import pickle

      tie = 0
      pcWon = 0
      playerWon = 0
      game_round = (tie + playerWon + pcWon) + 1

      # creates the main function used to start the program
      def main():

      welcomemenu()
      playGame = True
      global playGame
      while playGame:
      playGame = play()
      displayScoreBoard()
      prompt = input("Press enter to exit")


      # creates the welcomemenu function which displays start screen and requests user input. Opens .rps file for returning players.
      def welcomemenu():
      menuselect = int(input("Welcome to Rock, Paper, Scissors! nn1. Start New Game n2. Load Game n3. Quit nnEnter Choice:"))
      print("")
      global name
      if menuselect == 1:
      name = input("What is your name? ")
      global name
      print("Hello ", name, ".",sep="")
      print("Let's play!")
      playerFile = {name:"", playerWon: "", pcWon:"", tie:""}
      global playerFile
      global playerFileOpen

      newPlayer(name)
      elif menuselect == 2:

      name = input("What is your name? ")
      global name
      print("Welcome back ", name, ".", " Let's play!", sep="")
      loadPlayer(name)

      elif menuselect == 3:
      exit()
      return menuselect


      def loadPlayer(name):
      with open (name+".rsp", "r+") as playerFile:
      #playerFile = {name:"", playerWon: "", pcWon:"", tie:""}
      pickle.dump(playerFile, name, protocol=pickle.HIGHEST_PROTOCOL)
      def newPlayer(name):
      with open (name+".rsp", "r+") as playerFile:
      playerFile = {name:"", playerWon: "", pcWon:"", tie:""}
      pickle.dump(playerFile, name, protocol=pickle.HIGHEST_PROTOCOL)

      # creates the play function which calls the playerMenu function to determine player selection of RPS. Compares against the computer RPS selection
      def play():
      playerChoice = int(playerMenu())
      if playerChoice == 4:
      return 0
      else:
      pcChoice = pcGenerate()
      outcome = evaluateGame(playerChoice, pcChoice)
      updateScoreBoard(outcome)
      return 1


      # creates the player menu and asks for user selection of their RPS value.
      def playerMenu():
      print("Round ", (tie+playerWon+pcWon), "nn1. Rockn2. Papern3. Scissorsnn")
      menuSelect = input("What will it be? ")
      while not validateInput(menuSelect):
      invalidChoice(menuSelect)
      menuSelect = input("Invalid option.n1. Rockn2. Papern3. Scissorsn : ")

      return menuSelect


      # creates validateInput function for menuSelection function and checks if user input was valid
      def validateInput(menuSelection):
      if menuSelection == "1" or menuSelection == "2" or menuSelection == "3":
      return True
      else:
      return False


      # creates pcGenerate function to have the pc generate a value from 1-3 to play against player value
      def pcGenerate():
      pcChoice = random.randint(1,3)
      return pcChoice


      # creates evaulateGame function to check the players input against the computer. Prints results
      def evaluateGame(playerChoice, pcChoice):
      if playerChoice == 1:
      if pcChoice == 1:
      #tie
      print("You chose Rock. The computer chose rock. You tie!")
      return 0
      elif pcChoice == 2:
      #paper covers rock - pc won
      print("You chose Rock. The computer chose paper. You lose!")
      return -1
      else:
      #rock breaks scissors - player won
      print("You chose Rock. The computer chose scissors. You win!")
      return 1
      elif playerChoice == 2:
      if pcChoice == 1:
      #paper covers rock - player won
      print("You chose paper. The computer chose rock. You win!")
      return 1
      elif pcChoice == 2:
      #tie
      print("You chose paper. The computer chose paper. You tie!")
      return 0
      else:
      #scissors cut paper - pc won
      print("You chose paper. The computer chose scissors. You lose!")
      return -1
      else: #plyer choice defaults to 3
      if pcChoice == 1:
      #rock breaks scissors - pc won
      print("You chose scissors. The computer chose rock. You lose.")
      return -1
      elif pcChoice == 2:
      #scissors cut paper - player won
      print("You chose scissors. The computer chose paper. You win!")
      return 1
      else: #pc defaults to scissors
      #tie
      print("You chose scissors. The computer chose scissors. You tie!")
      return 0

      # creates endGame function to create a menu for a post-round user input request
      def endGame():
      endChoice = int(input("What would you like to do? nn1. Play Againn2. View Stasticsn3. QuitnnEnter choice:"))
      if endChoice == 1:
      playerMenu()
      elif endChoice == 2:
      displayScoreBoard()
      else:
      pickle.dump(new_player, np_open)
      playerFileOpen.close()
      player_file.close()
      exit()


      # creats updateScoreBoard function that keeps track of wins, ties, and losses. Updates the dictionary entries with appropriate values
      def updateScoreBoard(gameStatus):
      global tie, playerWon, pcWon
      if gameStatus == 0:
      tie +=1
      playerFile.update(tie +1)
      endGame()
      elif gameStatus == 1:
      playerWon += 1
      playerFile.update(playerWon +1)
      endGame()
      else:
      pcWon += 1
      playerFileOpen.update(pcWon +1)
      endGame()


      # creates invalidChoice function for menuSelect function. informs user of an invalid choice
      def invalidChoice(menuSelect):
      print(menuSelect, "is not a valid option. Please use 1-3")


      # creates displayScoreBoard function for statistics
      def displayScoreBoard():
      global tie, playerWon, pcWon
      print(name, ", here are your game play statistics...")
      print("Wins: ", playerWon)
      print("Losses: ", pcWon)
      print("Ties: ", tie)
      if pcWon == 0:
      print("Win/Loss Ratio: 1.00")
      else:
      print("Win/Loss Ration: ", "%.2f" %(playerWon/pcWon), )
      print("Rounds:", tie + playerWon + pcWon)
      endGame()
      main()






      python






      share|improve this question







      New contributor




      beardybaldy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      beardybaldy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      beardybaldy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 11 mins ago









      beardybaldy

      11




      11




      New contributor




      beardybaldy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      beardybaldy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      beardybaldy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.



























          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "196"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          beardybaldy is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f209128%2fpython-3-x-cannot-figure-out-pickling%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          beardybaldy is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          beardybaldy is a new contributor. Be nice, and check out our Code of Conduct.













          beardybaldy is a new contributor. Be nice, and check out our Code of Conduct.












          beardybaldy is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f209128%2fpython-3-x-cannot-figure-out-pickling%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          Refactoring coordinates for Minecraft Pi buildings written in Python