Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
API-Call, Json und und Pygal
#3
(Sep-03-2019, 03:59 PM)buran Wrote: line 10 should be for city in data["list"]:

Note that you will need to change also line 17-19, in order to get min and max temp, but I will leave this to you for now

Hey!
Thank you! I didn't see that :) ... anyway I've changed it but till got the same KeyError: "list"

    # Retrieve city names
    cities = []
    for city in data["list"]:
        cities.append(city["list"][1]["name"])

    # Retrieve temperatures
    min_temp, max_temp = [], []
    for elt in data["list"]:
        min_temp.append(elt["list"][0]["main"]["temp_min"])
        max_temp.append(elt["list"][0]["main"]["temp_max"])
Reply


Messages In This Thread
API-Call, Json und und Pygal - by starter_student - Sep-03-2019, 03:41 PM
RE: API-Call, Json und und Pygal - by buran - Sep-03-2019, 03:59 PM
RE: API-Call, Json und und Pygal - by starter_student - Sep-04-2019, 07:57 AM
RE: API-Call, Json und und Pygal - by buran - Sep-04-2019, 07:59 AM
RE: API-Call, Json und und Pygal - by buran - Sep-04-2019, 08:16 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020