Syntax Error in Project 9 Python code

I am getting syntax error for the Python code in Project 9. Please help me with the solution.

Hello @sohammethul10
can you show whole code and output error.

Please help me with the matter. The same is the case for the Project 10 of email. Pls guide me with the matter.

In your if statement where you write “response = sms.send_sms”, close the str(sensor_value) correctly, you have a typo there.

No I have typed that sentence correctly. But as there is no space in that line, it is showing$,but the code is present over there.

1 Like

print(" response received from twilio is " +str(response)). In this line of your code,u have missed ‘)’.

No, the brackets are closed neatly and the error is not in that line

@sohammethul10 you have an error at line 21.You haven’t closed the print statement. Line 21="print(“Response received from Twilio is: " + str(response))”.

Hi @sohammethul10
Please line number 21 in your code
Error code : print("Response received from Twilio is " +str(response)
Correct code : print("Response received from Twilio is " +str(response))
the bracket ‘)’ is missing
check it and update your process

If you write print() function in a program and someone using Python 2.x tries to run it, they will get an error. To avoid this, it is a good practice to import print function :

from __future__ import print_function

The from future import print_function ; to bring the print function from Python 3 into Python 2.x. Now your code works on both Python 2.x and Python 3.x . The future statements need to be near the top of the file because they change fundamental things about the language, and so the compiler needs to know about them from the beginning.

Python error: String index out of range python
What is the “string index out of range” error, why it occurs, the solution to remove the string index out of range error