title: I need help in making a count up counter with multiple inputs in Python2
body: <p>Help, I have made a count up counter that works partially. I have 2 inputs and i want the counter to up by 1 when either of the input is triggered. From the code that i have made i can only make the counter count up when i have 1 input once i add in and triggered the 2nd input i get an error saying "Invalid literal for int() with base 10" here is my code please help.</p>
  
  <pre><code>from time import sleep
  import RPi.GPIO as GPIO
  import os
  
  
  GPIO.setmode(GPIO.BOARD)
  
  button1=40
  button2=11
  
  GPIO.setup(button1,GPIO.IN,pull_up_down=GPIO.PUD_UP)
  GPIO.setup(button2,GPIO.IN,pull_up_down=GPIO.PUD_UP)
  
  while(1):
              if GPIO.input(button1)==0:
                      f = open("counter1.txt","r+")
                      counter = int(f.readline())
                      counter += 1
                      f.seek(0)
                      f.write(str(counter))
                      f.close()
                      print (counter)
                      sleep(1)
  
              if GPIO.input(button2)==0:
                      f = open("counter2.txt","r+")
                      counter = int(f.readline())
                      counter += 1
                      f.seek(0)
                      f.write(str(counter))
                      f.close()
                      print (counter)
                      sleep(1)
  
              else:
                      counter = 0
                      f = open("counter.txt","w+")
                      f.write(str(counter))
                      f.close()
                      print (counter)
  </code></pre>