So I needed to create a script in Python that allows me to calculate distance from one point to another using coordinates. The first point had fixed coordinates and the coordinates to the second point should be through user input. I managed to create that script. The last thing I have to do is to create a statement that allows me to intercept incorrect entries (e.g., letters instead of numbers, nonsensical Degree inputs) using e.g. try...except. So I'm having a bit trouble here since I'm only getting started with Python. Here's my code:
lat1= 47.79
lon1=13.00
name= "Entfernung "
typ= "Km"
userEingabe= input("Geben sie lat2 ein:")
userEingabe2= input("Geben sie lon2 ein:")
lat2 = float(userEingabe)
lon2 = float(userEingabe2)
import math
distanz= 6370*math.acos(math.sin(math.radians(lat1))*math.sin(math.radians(lat2))+math.cos(math.radians(lat1))*math.cos(math.radians(lat2))*math.cos(math.radians(lon2)-math.radians(lon1)))
print(name+str(distanz)+typ)
input("Press return to close this window...")
How can I do this?