App 4: Weather App with a Real API / Build the weather app
Lesson 4 of 10
Reading JSON
JSON from an API is just nested dictionaries and lists. Follow the keys step by step to reach the value you want.
Key points
- data["current"]["temperature_2m"]
- Print the structure first
- Units are in data["current_units"]
temp = data["current"]["temperature_2m"]
wind = data["current"]["wind_speed_10m"]
unit = data["current_units"]["temperature_2m"]
print(f"It's {temp}{unit} with wind at {wind} km/h")Your turn
Print the temperature and wind in a friendly sentence.
Quiz · +10 XP
How do you reach a value inside nested dictionaries?
Log in to save progress and earn XP.