title: Adding to a variable not working?
body: <p>Adding a number to the variable isn't working? (This is once again the rock paper scissors program.)</p>
  
  <pre><code>    import random
  hscore = 0
  cscore = 0
  tries = 0
  
  
  #computer choice
  rock = ("rock")
  paper = ("paper")
  scissors= ("scissors")
  rps = (rock, paper, scissors)
  
  #human wins
  def humanfunction():
      hscore +=1
      if choice == "rock":
          if cchoice == scissors:
              hscore +=1
              print("Human wins this round.")
      if choice == "scissors":
          if cchoice == paper:
              hscore +=1
              print("Human wins this round.")
      if choice == "paper":
          if cchoice == rock:
              hscore +=1
              print("Human wins this round.")
  def computerwin():
  
  #computer wins
      cscore +=1
      if cchoice == "rock":
          if choice == scissors:
              cscore +=1
              print("Computer wins this round.")
      if cchoice == "scissors":
          if choice == paper:
              cscore +=1
              print("Computer wins this round.")
      if cchoice == "paper":
          if choice == rock:
              cscore +=1
              print("Computer wins this round.")
  def tie():
  
      if cchoice == choice:          
          print("It's a tie!")
  
  #choosing
  while 0 == 0:
  
      choice = input("\nWhat do you choose? &lt;rock, paper, scissors&gt;: ")
      tries +=1
      cchoice = random.choice(rps)
      humanfunction()
      computerwin()
      tie()
      print(hscore, cscore)
      print("Human choice: ",choice)
      print("Computer choice: ",cchoice)
      print("Finished game number", tries)
      if tries == 10:
          print("limit reached")
          break
  </code></pre>
  
  <p>When I run the code it shows this (ignore the error beforehand):</p>
  
  <p><a href="https://i.stack.imgur.com/822mX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/822mX.png" alt="enter image description here"></a></p>
  
  <p>The human chose paper and the computer chose rock, which means the human beats the computer--but the score for the human didn't increase the next game. Functions have been messing up my code super badly for some reason.</p>
  
  <p>The <code>hscore</code> is there again in the function because without it, the output will say something about a local variable being reference beforehand. (This is a class assignment and we cannot use things we haven't gone over yet.) So adding a global would not help. The choices are defined in the code later on. I just didn't include it as I wanted to just show the part where the variable is being added to.</p>