title: Using python to run a C++ program and test it
body: <p>Suppose I have a simple C++ program that takes in inputs and outputs some string. Like this (actual program is much more complicated but still text based):</p>
  
  <pre><code>$ ./game
  $ what kind of game? type r for regular, s for special.
  $ r
  $ choose a number from 1 - 10
  $ 1
  $ no try again
  $ 2
  $ no try again
  $ 5
  $ yes you WIN!
  </code></pre>
  
  <p>I haven't used Python before, but is it possible to write a python script to run this program, feeds it input, and outputs the results to standard output? I have ask the question <a href="https://stackoverflow.com/questions/6783256/run-c-program-in-c-program">here</a> about running it using C++ but it seems much too complicated. It would be awesome it you could direct me to some code examples. Any help would be appreciated.</p>