Why my code doesn't work

Dear Sir, when I run the code given in the course, the robot moves:

from robot_control_class import RobotControl

robotcontrol = RobotControl()

a = robotcontrol.get_laser(360)

if a < 1:
    robotcontrol.stop_robot()

else:
    robotcontrol.move_straight()

print ("The laser value received was: ", a)

But when I execute my code, given below, the robot doesn’t move, why?


Hello @abdulbasitisdost,

I think you already found the solution to your own question by yourself. If this is the case, please close or edit the original question so that we don’t have to check it again.

Best,

No Sir. I didn’t. That solution is the one I took from the course. My solution as I’ve given below throws error. Is it because the function move_straight() and stop_robot() don’t return any value and so we shouldn’t store them in a variable( like s or m in my case)

Hi @abdulbasitisdost,

yes, given that the functions don’t return any value, you don’t need to save the return value in any variables.

When you define the m and s variables, you are already calling the functions. The functions should be called as exemplified in the exercise solution after the value of get_laser(360) is analyzed.

1 Like