-1

This is a bit of unfinished code to create a calculator, However it keeps on giving me a syntax error.

n1=input("Enter Number: ")
Eo=input("Enter Operator: ")
if Eo=="+" or "-" or "*" or "/":
    answer= n1+str(Eo)+input("Enter 2nd number: ")

Traceback (most recent call last):
  File "C:/Python27/Programming/Calculator.py", line 2, in <module>
    Eo=input("Enter Operator: ")
  File "<string>", line 1
    +
    ^
SyntaxError: unexpected EOF while parsing
vaultah
  • 44,105
  • 12
  • 114
  • 143
  • This line doesn't do what you think it does: `if Eo=="+" or "-" or "*" or "/":` – Andy Sep 22 '15 at 15:56
  • Also see [How do I test one variable against multiple values?](http://stackoverflow.com/a/15112149) as you are making a logic error in your `if` test. – Martijn Pieters Sep 22 '15 at 15:57
  • What does it do then?, I want it to do the answer calculation when one of the operators have been selected.. – Matthew Tadesse QG Sep 22 '15 at 15:58
  • Please write a program that writes hundred times: "I will not use `input` with Python 2.x until I can explain in detail what it does." – Matthias Sep 22 '15 at 16:11

1 Answers1

0

Two issues:

1) Use raw_input instead of input.

2) To check Eo against multiple values, use

if Eo in ("+", "-", "*", "/"):
NPE
  • 486,780
  • 108
  • 951
  • 1,012