Invalid syntax error - copied code but it does not work

   1760   2   1
User Avatar
Member
5 posts
Joined: Feb. 2020
Offline
Hello! I am following a tutorial in which I am required to type in and copy this haversine formula code. For some reason, I am unable to get it working even when I copied it completely? Am I missing something? I just do not understand what I have done wrong here. I am quite new to coding so I might have effed it up in some really weird way.

Here is the error:

Error
Python error: SyntaxError: ('invalid syntax', ('', 8, 30, ‘def haversine(coord1, coord2)\n’))




Here is my code:




Here is said video tutorial i am following: https://vimeo.com/369809944 [vimeo.com] at 4:11.

Any kind of help would be greatly appreciated!
Edited by Andromonoid - March 16, 2020 00:46:23

Attachments:
2020-03-16 05_43_21-C__Users_Markus_Documents_houdini18.0_Projects_Derwentwater01.png (23.7 KB)

User Avatar
Member
238 posts
Joined: Jan. 2013
Offline
In python, after the function name and arguments in brackets, a colon always follows. Therefore, it will be right

def haversine(coord1, coord2):
User Avatar
Member
5 posts
Joined: Feb. 2020
Offline
hou.alex.get
In python, after the function name and arguments in brackets, a colon always follows. Therefore, it will be right

def haversine(coord1, coord2):

Thank you! Now it works and no errors! I got to look up coding a bit more so I don't stumble into beginner errors like this.

I appreciate the help!
  • Quick Links