Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def add_city_data(country, city, population, area):
- data = load_data()
- density = round(population / area, 2)
- if area
- else 0
- city_data = {"Core City": city, "Population": population, "Area": area, "Density": density}
- if country not in data:
- data[country] = []
- data[country].append(city_data)
- save_data(data)
- print(f"Data for {city}, {country} added successfully.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement