It says exactly what it means: You began defining a function, but didn't indent the lines that are supposed to be a part of that function (Python doesn't know which lines should be part of it, but it knows it should have at least one line). After any line ending in :
, you're supposed to indent (standard is four spaces) and keep indenting until you want that block to be done (at which point you dedent). You need to indent the contents of both the function and the if
block:
def query_raw(text, url="https://mywebsite.com/plain"):
return requests.post(url, data={'sample_text': text}).json()
if __name__ == '__main__':
print(query_raw("Give me the list of users"))
Python is a whitespace sensitive language: If you copy in sample code without preserving the indentation, it will fail.