+ 2
umm
def calculator(): in = int(input('first number: ')) in2 = (input('enter divide, multi, minus, plus.')) in3 = int(input('second number: ')) if in2=='divide': print(in / in3) if in2=='multi' print(in * in3) if in2=='minus': print(in - in3) if in2=='plus': print(in + in3) Syntax error in line2
3 Réponses
+ 5
Just a few small problems:
In Python, the word 'in' is reserved as a conditional statement, so therefore cannot be set as a variable name. To fix that, I would recommend changing it to in1 to avoid that issue.
For the second if statement that runs the condition based on if in2 is equal to the string 'multi', you forgot to add the colon which will result in an error.
Lastly, you don't seem to have called the function anywhere outside of it. This results in the program skipping over the calculator entirely. To avoid this, add a line that calls the calculator function outside of the function itself so it will actually run.
+ 1
Omg I did not see that on the 2nd and 3rd problems. Thx man!
+ 1
I didn't know that in wouldn't work as a variable tho