Below is my code which I am using to help me do my mathematics homework. When I run it, I get an 'invalid syntax' message with the variable 'y1' highlighted (look below for which one). I was wondering why, so when I looked up on this website similar titles nothing useful came up. So, what do I do? How do I stop y1 getting a syntax error?

import time

print("Hello, and welcome to the midpoint-finder-9001! Please insert the x1, y1, x2, and y2 coordinates when asked.")
x1=int(input("Please insert the x1 coordinate")
#This one below  VVVV. I've even tried replacing it with random stuff like 'wef'
# but the variable name still gets highlighted. Even using # doesn't work as it
#just goes onto x2 and says that *that* also has a syntax error.
y1=int(input("Please insert the y1 coordinate")
x2=int(input("Please insert the x2 coordinate")
y2=int(input("Please insert the y2 coordinate")

print("Thank you! Now please wait while I find the midpoint!")


print("Interpreting co-ordinates....")
print("Drawing line....")
print("Finding midpoint location....")
print("Finding co-ordinates...")

print("The midpoint has been found! The midpoint co-ordinate is",ansx,",",ansy,".")
yn=raw_input("Would you like to see the working out? (yes/no only!)  ")

if yn.lowercase() == "yes"
    print("The working out is:")
    print("(",x1,"+",x2,") / 2")
    print("(",y1,"+",y2,") / 2")
    print("Ok then! Have a great day!")

closed as off-topic by Steve Robillard, goldilocks Oct 15 '17 at 13:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be specific to the Raspberry Pi within the scope defined in the help center." – Steve Robillard, goldilocks
If this question can be reworded to fit the rules in the help center, please edit the question.


You have mismatched parenthesis (you are missing the closing parenthesis for the int function).

Change this line:

y1=int(input("Please insert the y1 coordinate")


y1=int(input("Please insert the y1 coordinate"))

Note: You have the same problem in the next two lines.

Not the answer you're looking for? Browse other questions tagged or ask your own question.