# Dictionary of cities 
# Keys are city names(strings)
#Values are distances (integers)

#iterating for city in cities: iterates over the keys(city names)
cities = {
    'Montreal': 958,
    # 958 > 0 True --> Best = 'Montreal', distance = 958
    'Chicago': 5259,
    # 5259 > 958 --> Best = 'Chicago', distance = 5259
    'Nairobi': 982,
    # 982 > 5259 False --> No change
    
    'Rome': 584,
    #584 > 5259 --> False --> No change
}
#Tracking variables
best = ''
distance = 0

# For each city, look up its distance with cities[city]
# If that distance is greater than the current distance, update both: 
# best becomes that city 
# distance becomes that city's distance 

for city in cities:
    if cities[city] > distance:
        best = city
        distance = cities[city]

# prints the city with the maximum distance and the maximum value
print(best, distance)

#prints Chicago, 5259

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: