For some reason my task 3 wont pass

I get the points for my get_laser_readings but not main does anyone have any ideas why?

from robot_control_class import RobotControl

import time

class ExamControl:

    def __init__(self):

        self.rc = RobotControl()

    def get_laser_readings(self):

        #returns left and right laser readings

        left = self.rc.get_laser(719)

        right = self.rc.get_laser(0)

        return left, right

    

    def main(self):

        #behavior

        left, right = self.get_laser_readings()

        while left != float("inf") and right != float("inf"):

            self.rc.move_straight()

            left, right = self.get_laser_readings()

        #time.sleep(1)

        self.rc.stop_robot()

@thunderbootyclap

def init(self):
   self.rc = RobotControl()

This should been as below. You need to add __before and after init to be considered a constructor of the class.

def __init__(self):

Also, there should have been an indent after class ExamControl::
Your code:

class ExamControl:
def init(self):
   self.rc = RobotControl()
def get_laser_readings(self):
   #returns left and right
.

def main(self):
    #code

This should have been as below with an indent (click on tab once):

class ExamControl:
    def __init__(self):
        self.rc = RobotControl()
    def get_laser_readings(self):
        #returns left and right
    def main(self):
    #code
.
.
.

@Joseph1001
Those are formatting errors on my part when asking the question, in my task3.py I do have init and an indent for the class. For some reason the double underscores are bolding init

I just formatted the code to see it better.

Next time, for formatting, you can use the next three symbols (but without space) rather than “>” to format the code.

` ` `
# the code here, 
    # with correct identation
` ` `

Hi @thunderbootyclap ,

The problem with your script is the same that happened with other student pointed below.

Please follow the link below to better understand the explanation.

Thank you for the markup and help with my code, that was the issue. More specifically the while loop with and as described by this post

1 Like