Search code examples
pythonsensorsraspberry-pi3temperature

Python script: Syntax error


I am trying to program a DHT11 temperature and Humidity sensor using my Raspberry Pi 3 model B. I am using a Python script on the shell, but it is not working because here because of a syntax error.Please find my script capture in the link below. I am trying to run it on the raspberry pi terminal and the error message is in the print statement.


Solution

  • You are missing parenthesis around the print statements. The correct syntax is:

    print("Temperature: ", temperature," C   humidity: ", humidity)
    

    Python 3 requires print statements containing text to be inside of (" "), variables inserted like:

    print(" text ", variable, "more text")