How do i save this python code to text file.? [closed]

It’s off-topic but if you just want to write the setup and punchline values to a text file you can do something like this:

# Dependencies
import json
import requests 

# Specify the URL
url = "https://official-joke-api.appspot.com/jokes/programming/ten"

# Make request and store response
r = requests.get(url)

print("Status code:", r.status_code)

jokes = json.loads(r.text)

with open("outfile.txt", "w") as f:
    for joke in jokes:
        f.write("{}:{}\n".format(joke["setup"], joke["punchline"]))