0

I need help for Boolean expressions. When someone inputs (x or y), (x and y),etc..... It gives a truth table. I have everything except when I try do int((m)) on the line it gives me an error.

m = raw_input("Give an expression :")

list=[(0,0),(0,1),(1,0),(1,1)]

for (x,y) in list:

    print[ x, y ],int(m)
  • First of all you have `int((n))` not m , then you should not put the `m` in parenthesis,also you need to add the error that you get to question! – Mazdak Apr 05 '15 at 18:53

2 Answers2

1

Use eval().

m = raw_input("Give an expression :")
list=[(0,0),(0,1),(1,0),(1,1)]
for (x,y) in list:
    print [ x, y ], eval(m)

Example: try (x and y) or y when you execute the script.

More information on What does Python's eval() do?

Community
  • 1
  • 1
TimeString
  • 1,778
  • 14
  • 25
0

You mentioned

"when I try do int((m)) on the line it gives me an error"

Kindly specify exactly what error are you getting.

Prav001
  • 343
  • 1
  • 5
  • 12