def get_hostname(): response = raw_input("Please enter your name: ") body = '[{{"hostname": "{}"}}]'.format(response) return body print get_hostname()I expect you want something like this, but not sure about quotes, etc.
Also if you want to create a json, better use json module
import json def get_hostname(): response = raw_input("Please enter your name: ") body = [{'hostname':response}] return json.dumps(body) print get_hostname()
Also, if you don't have really good reason for using python2 (like maintaining old code base) you should be using python3 (latest is python 3.6.5)
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