Menu
Coddy logo textTech

Displaying Appropriate Results

Lesson 10 of 10 in Coddy's API in Python course.

challenge icon

Challenge

Medium

Now that you have successfully sent GET requests to an API server, let's display the specific results that we want by accessing nested dictionary values.

Instructions:

  1. Send a GET request to: https://wttr.in/London?format=j1
  2. Save the requests.get() object to a variable called response
  3. Save response.json() to a variable called data
  4. Access the current conditions, which are nested inside data["current_condition"][0], and save them to a variable called current
  5. Save current["temp_C"] to a variable called temperature
  6. Save current["windspeedKmph"] to a variable called wind
  7. Create a variable called city and set it to "London"
  8. Print all three variables in a formatted message

Try it yourself

import requests

# Step 1: Send GET request
response = # Your code here

# Step 2: Parse JSON response
data = # Your code here

# Step 3: Extract specific data
temperature = # Your code here
wind = # Your code here
city = # Your code here

# Step 4: Display results
print(f"City: {city}")
print(f"Temperature: {temperature}")
print(f"Wind: {wind}")

All lessons in API in Python