0

I am trying to extract historical weather data using wunderground python API, however I am repeatedly getting an error. Can some one please help out:

import requests
def get_precip(gooddate):
urlstart = 'http://api.wunderground.com/api/INSERT_KEY_HERE/history_'
urlend = '/q/Switzerland/Zurich.json'

url = urlstart + str(gooddate) + urlend
data = requests.get(url).json()
for summary in data['history']['dailysummary']:
    print ','.join((gooddate,summary['date']['year'],summary['date']['mon'],summary['date']['mday'],summary['precipm'], summary['maxtempm'], summary['meantempm'],summary['mintempm']))

Error:

  File "<ipython-input-49-802c58ba5307>", line 9
    print ','.join((gooddate,summary['date']['year'],summary['date']['mon'],summary['date']['mday'],summary['precipm'],'maxtempm',summary['meantempm'],summary['mintempm']))
            ^
SyntaxError: invalid syntax
U13-Forward
  • 69,221
  • 14
  • 89
  • 114
user4943236
  • 5,914
  • 11
  • 27
  • 40

1 Answers1

3

If you are using Python 3, print is a function, not a statement, and requires parentheses.

print(','.join((gooddate,summary['date']['year'],summary['date']['mon'],summary['date']['mday'],summary['precipm'], summary['maxtempm'], summary['meantempm'],summary['mintempm'])))
Alasdair
  • 298,606
  • 55
  • 578
  • 516