Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
API-Call, Json und und Pygal
#4
(Sep-04-2019, 07:32 AM)starter_student Wrote: anyway I've changed it but till got the same KeyError: "list"
it's on line 9 and 10 now. as I said you need to change these too.

city_names = []
min_temps = []
max_temps = []
for city in data['list']:
    city_names.append(city['name'])
    min_temps.append(city['main']['temp_min'])
    max_temps.append(city['main']['temp_max'])

print(city_names)
print(min_temps)
print(max_temps)
Output:
['Moscow', 'Kiev', 'London'] [23, 29, 16.67] [25, 31.67, 20.56]
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

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 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