0

I made a simple program where it asks for the user to type in 2 numbers, and the program will add the numbers. For some reason my program gives me an error and I am not sure why. The code is below.

choice = input("Enter Choice")
choice2 = input("Enter Choice")

num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))

if choice == '1':
   print(num1"+",num2,"=", add(num1,num2))

The error states Syntax Error - Invalid Syntax.

Any help would be appreciated.

1
  • I suggest finding an capable IDE that will highlight such syntax errors as you type. Commented Oct 17, 2019 at 3:15

2 Answers 2

2

You miss a ","

choice = input("Enter Choice")
choice2 = input("Enter Choice")

num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))

if choice == '1':
   print(num1, "+", num2, "=", add(num1,num2))
Sign up to request clarification or add additional context in comments.

Comments

0

'add' is not defined. Try below:

choice = input("Enter Choice") choice2 = input("Enter Choice")

num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: "))

if choice == '1': print(num1, "+", num2, "=", num1+num2)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.