Fantastic, many thanks for the reply and the references. This performed beautifully for ENSG00000169174; however, some other Ensembl ID's throw the following error:
Traceback (most recent call last):
File "WEEK10.py", line 15, in <module>
r.raise_for_status()
File "/Users/oars/anaconda/lib/python2.7/site-packages/requests/models.py", line 928, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://rest.ensembl.org/sequence/id/ENSG00000186642?type=cds
Perhaps this is coming from Ensembl's API and not with the structure of the script?