How to resolve "ValueError: invalid literal for int() with base 10" in Python?
<p>I'm having a little trouble with a calculator that I'm making. I need to make it where it can add, multiply, divide, and subtract if you put them as the operator then it will follow which one it is. My code looks like this:</p>

<pre><code>   a= int( input("First Number: "))

   int( input("First Operator: "))

   b= int( input("Second Number: "))

   if (operator == "+"):
       c=a+b
   elif(operator == "-"):
       c=a-b
   elif(operator == "*"):
       c=a*b
   elif(operator == "-"):
       c=a/b



   print(c)
</code></pre>

<p>Every time I enter either a <code>+,-,*,or/</code> as the operator it give me this:</p>

<pre><code>   operator=int( input("Operator: "))
   ValueError: invalid literal for int() with base 10: '/'
</code></pre>

<p>I know this means that I need an integer, but how can I fix it?</p>

<p>You are trying to turn a char variable, in this case the operator, in an int one. Since the compiler cant turn the operator in int it will return this error. If you just declare a variable called operator it will work, your code will look like this:</p>

<pre><code>a= float( input("First Number: "))

operator =input("First Operator: ")

b= float( input("Second Number: "))

if (operator == "+"):
    c=a+b

elif(operator == "-"):
    c=a-b

elif(operator == "*"):
    c=a*b

elif(operator == "-"):
    c=a/b
</code></pre>

python