If that is all your code, you just define the get_request() function but never call it. Note that lines#9 and 12 are indented and are in fact part of function itself. Unindent lines#9 and 12 one level. The print should remain part of the function.
import requests import json import sys def get_request(api_key): api_url='https://api.nasa.gov/planetary/apod' r= requests.get(api_url, headers = {"Content-Type": "application/json", "access_key": api_key}) print(r.content) api_key ='<my api key>' get_request(api_key)also if the response is json format, you can use
r.json()
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
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs