

- Let's look at a Python script that calculates the distance between two locations.
- It accepts two cities as input and calculates longitude and latitude for them.
- Finally, the result will be displayed in kilometres.
from geopy.geocoders import Nominatim
from geopy.distance import geodesic
- Set the user agent where all the data will be fetched using the Nominatim function; in our example, it'll be Google Map.
- Take the user's input for two cities.
- Now, using geocode, retrieve all of the data, including all of the city's details, such as latitude, longitude, and so on.
- Both cities longitude and latitude should be saved in separate variables.
- Use geodesic to determine the city's name based on its longi and lati.
- Finally, in kilometers, display the result.
