title: Is there a way to replace a piece of string with a logical statement (not, and, or)
body: <p>So, I've just started learning Python and I got an assignment to make a program that takes a propositional calculus formula and values of X, Y, and Z (True or False) as input. Then it should write if the answer if true or false. Formula should consist of only 3 operations: - (not), &amp; (and), v (or). Variables in the formula should only be X, Y, Z and the all can appear 0 or more times. </p>
  
  <hr>
  
  <p>Examples of possible formulas:</p>
  
  <ul>
  <li>Y</li>
  <li>-(-(YvX)&amp;Y)</li>
  <li>--X (double negative)</li>
  <li>-Z&amp;Z</li>
  </ul>
  
  <p>Value of variables should be given in binary like this:
   010 (X = f, Y = t, Z = f). For value of variables, I did this</p>
  
  <pre><code>value = input("Value: ")
  
  X = value[0]
  Y = value[1]
  Z = value[2]
  
  if X == "0":
      X = False
  elif X = "1":
      X = True
  else:
      print("False input")
  
  if Y == "0":
      Y = False
  elif Y = "1":
      Y = True
  else:
      print("False input")
  
  if Z == "0":
      Z = False
  elif Z = "1":
      Z = True
  else:
      print("False input")
  </code></pre>
  
  <hr>
  
  <p>Pretty sure that there is a better way to do this but this should still work. The problem is in reading the formula. My idea was to replace the symbols (-,&amp;,v) with not, and, or. Something like this:</p>
  
  <pre><code>a = input()
  print(a.replace("v", or))
  </code></pre>
  
  <p>But you can't do that, so I have no idea how to do this.</p>