title: Meta Algorithm for Finite State Machine. How to fix error "cannot concatenate 'str' and 'int' objects?
body: <pre><code>alphabet = open('alphabet.txt', 'r')
  finalStates = open('finalStates.txt', 'r')
  startState = open('startState.txt', 'r')
  states = open('states.txt', 'r')
  transitionTable = open('transitionTable.txt', 'r')
  
  start = startState.readline()
  curState = start[1]
  final = finalStates.readline()
  finalState = final[1]
  
  import sys
  input = sys.argv[1]
  i = 0    
  
  for c in input:
      while True:
          pirate = transitionTable.readline()
          if not pirate: break
          value = 2
          index = pirate[value]
          if (curState == index and input[i] == (index + 4)):
              curState = pirate[index + 9]
              if(curState == finalState):
                  print ('accept')
          value = value + 13
          i = i + 1
  </code></pre>
  
  <p>Here is my code that uses 5 files and a string from the command line and runs them through a finite state machine and returns accept or reject. At <code>if(curState == index and input[0] == (index + 4)):</code> is where my error occurs because im assuming the <code>input</code> from the command line is a string and cant be compared to type int of <code>(index + 4)</code> from the transitiontable.txt file. However I tried converting them to be the same type and it didnt work and dont know how to move forward.</p>
  
  <p>the transitiontable file is in this format:
  "q0","b","q1"
  "q0","a","NULL"
  and so on with the first state then the char that is tested and the state it would then move to.</p>