I've managed to iron out the bugs previous to this one showing up and I've copied the code exactly as is stated in the chapter but I am getting this error being thrown up and I can't seem to fix it:
File "xkcd.py", line 34
continue
^
SyntaxError: 'continue' not properly in loop.
Here is my code:
comicElem = soup.select('#comic img')
if comicElem == []:
print('could not find comic image.')
else:
try:
comicUrl = 'http:' + comicElem[0].get('src')
# Download the image.
print('Downloading image %s...' % (comicUrl))
res = requests.get(comicUrl)
res.raise_for_status()
except requests.exceptions.MissingSchema:
# skip this comic
prevLink = soup.select('a[rel="prev"]')[0]
url = 'http://xkcd.com' + prevLink.get('href')
continue
I understand the obvious, because of the error being perfectly clear but as a newbie copying code straight from the site and not coming across this sort of thing previously, I am struggling to understand where the issue really is.