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. I am trying to run it on the raspberry pi terminal and the error message is in the print statement.
Asked
Active
Viewed 1,652 times
-5

Alan Kavanagh
- 9,425
- 7
- 41
- 65

KGosalia
- 39
- 1
- 5
-
Welcome to SO. You should consider adding your code to the question instead of having it as a screenshot. You wont get much help if the people trying to help you cant reproduce (c+p) your code to debug the problem – Alan Kavanagh Oct 16 '17 at 21:59
-
3Please add your code as text to the question. Screenshots are annoying to try locally. In this case though, it's pretty clear that the problem is with your print statement being incorrectly indented... – Shadow Oct 16 '17 at 21:59
-
Also add your exception to the question, we dont know what problem you've hit – Alan Kavanagh Oct 16 '17 at 22:00
-
You should also fix your formatting, everything is messed up – Alan Kavanagh Oct 16 '17 at 22:00
-
Use an editor that understands python formatting. – stark Oct 16 '17 at 22:03
-
1As others have said, images of code are useless to us. See [this Meta post](https://meta.stackoverflow.com/a/285557/62576) for a list of many reasons why you should never post code in any form other than text. Also, see [ask]. *a syntax error* means that you got an error message, which means that message is on the screen right in front of you, which means there is absolutely no reason for it not to have been included in your post. You're asking us for **free help** to solve **your problem**, and it's in your best interest to make it as easy as possible for us to give you that help. – Ken White Oct 16 '17 at 22:12
1 Answers
0
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")

Harvey Fletcher
- 1,167
- 1
- 9
- 22