'How to concatenate value from for loop to empty string

I am trying to find "lat" and "lon" keys in IP data dictionary and then add the values of those keys to empty "lat" and "lon" variables. Then add them in google variable, to get working google maps link. Please help.

import requests

r = requests.get(f"http://ip-api.com/json/50.40.70.18?fields=24895487")
data = r.json()
print(data)
lat = ""
lon = ""
google = f"https://maps.google.com?q={lat},{lon}"
for key, value in data.items():
    if key == 'lat':
        lat += str(value)
    if key == 'lon':
        lon += str(value)
print(google)


Solution 1:[1]

lat = data.get("lat")
lon = data.get("lon")
google = f"https://maps.google.com?q={lat},{lon}"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cihiman