Mailgun code: syntax error

I’d typed out the code for the Mailgun configuration of the temperature monitor exactly as it is given in the lesson. But, when I try to execute it, I get the following error:

except Exception as e:
^
SyntaxError: invalid syntax

I’d gotten a similar error when I first tried to execute the SMS code for the monitor, but it was resolved once I varied the indentation. The same didn’t work for this code.

Here’s the code in case there’s actually an error I didn’t notice:

Hoping for a response soon. Thanks!

Hello @shilpa.namboodiri, instead of writing these 2 lines:
response_text = json.loads(response.text)
print(“Response received from Mailgun is:” + str(response_text))

Try replacing those 2 lines with this line of code:
print(“Response received from Mailgun is:” + response.text)
Hope this helps!
Thank you

@shilpa.namboodiri Have you used both tabs and spaces to indent your code? If yes, then please use only one method of indenting as using both tabs and spaces in your code may cause an indentation issue.

@shoeb.ahmed I’d first indented with tabs. When the code showed the error, I switched to indentation using spaces. That produced the same error.

@shilpa.namboodiri So you have now indented the entire code with spaces?

It was indented with spaces as per the image.

It worked! Thanks a bunch!

1 Like