I’m stuck here. Tried my best but couldn’t solve it
It is most likely an indentation error. Make sure to keep in mind of the space on the left hand side. Avoid using space, use a tab instead to manually give the space on left hand side.
Refer to below code and look at the space and the comment
def get_sensor_vallue: // new block
# ''' Returns the sensor value.....''' // remove this part OR add '#' in front as it is only a comment.
try: // new block
response = mybolt.analogRead(pin) // inside the block
data = ...
if data(data["success"] != 1: // new block
.
.
return -999
sensor_value = int (data["value"]) // outside prev block
return sensor_value
except Exception as e: // new block and same line as 'try'
print(" Something went wrong...") // inside the block
.
.
return -999
Indentation block means, the part of the code is inside the above condition. In C++ we use { } so we don’t get any such error in there. But python does not have that, so it is necessary to mind the gaps.
1 Like
See, you have used double quote " before ok and one quote ’ after that.
Correction [“ok”] or [‘ok’] .