-1

Hey I have this simple code for a Haversine Formula (without radial conversion), but it keeps giving me the error of invalid syntax.

I looked everywhere but cant find any solution. It should work!

import math
def distance(lat1, lat2, lon1, lon2)
a1= (math.sin(lat2 - lat1 / 2 ))
a2= (math.cos(lat1) * math.cos(lat2) * (math.sin(lon2 - lon1 / 2) **2 ))
a ** 2 = a1 + a2
b ** 2 = 1 - (a **2)
d= 2 * math.atan2(a, b)
return d
Jan
  • 11

1 Answers1

1

I assume this should be Python. You have to declare functions as

def function(a, b, c, d):
    code in function
code outside function

The : is absolutely required as is indenting (please always use four spaces).

MKesper
  • 456
  • 5
  • 16