Learn cities = ['London', 'Birmingham', 'Manchester'] for city in cities: url = f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric" data = requests.get(url).json
Get a clear, practical understanding of cities = ['London', 'Birmingham', 'Manchester'] for city in cities: url = f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric" data = requests.get(url).json
Free · starts instantly · no signup required
What you'll cover
- 1Understand Python ListsLearn what a Python list is and how to create one.
- 2Iterating with For LoopsUnderstand how to loop through items in a list.
- 3Introduction to Web APIsLearn what an API is and why it's used.
- 4Making HTTP RequestsUnderstand how to use libraries like 'requests' to fetch data.
- 5Understanding JSON DataLearn how to interpret and use data returned in JSON format.
- 6Putting It All TogetherCombine lists, loops, API requests, and JSON to get city weather data.
Ready to learn cities = ['London', 'Birmingham', 'Manchester'] for city in cities: url = f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric" data = requests.get(url).json?
Your adaptive tutor is one tap away. Start now and pick up anytime.