Error in python code for email alert

there is an error in the python code for email alert for temperature sensor reading from mailgun
the error is showing in the try command
can anyone help to debug it

there was spacing error

I am facing an issue with the try syntax. I have used the same syntax in creating code for sms alert in python, but for the email alert code it is showing invalid syntax.

Please help me with this issue

Hi @hisana6123,
Add a closing bracket to the print statement that is before the try statement just like -
print(‘Sensor value is:’ + str(data[‘value’]))

For such errors, I would recommend you to always check the previous line from the line which has syntax error. Like in your case, you forgot to put one more closing parenthesis in the previous line.

@kushag09 Thank you so much. I rechecked the statements after try: a lot of times but did not pay attention to this.

1 Like