# For some reason my task 3 wont pass

**URL:** <https://get-help.theconstruct.ai/t/for-some-reason-my-task-3-wont-pass/14773>\
**Category:** Python Basics For Robotics\
**Tags:** python3, final-exam, ros\
**Created:** [January 15, 2022, 7:21am UTC](https://get-help.theconstruct.ai/t/for-some-reason-my-task-3-wont-pass/14773 "2022-01-15T07:21:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![thunderbootyclap](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/t/a4c791/32.png) [@thunderbootyclap](https://get-help.theconstruct.ai/u/thunderbootyclap)\
**Post date:** [January 15, 2022, 7:21am UTC](https://get-help.theconstruct.ai/t/for-some-reason-my-task-3-wont-pass/14773/1 "2022-01-15T07:21:30Z")

</div>

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

```auto
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()

```

---

<div class="post-metadata">

**Author:** ![Joseph1001](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/joseph1001/32/7077_2.png) [@Joseph1001](https://get-help.theconstruct.ai/u/Joseph1001)\
**Post date:** [January 15, 2022, 5:27pm UTC](https://get-help.theconstruct.ai/t/for-some-reason-my-task-3-wont-pass/14773/2 "2022-01-15T17:27:29Z")

</div>

@thunderbootyclap

```auto
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.

```auto
def __init__ (self):

```

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

```auto
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):

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

```

---

<div class="post-metadata">

**Author:** ![thunderbootyclap](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/t/a4c791/32.png) [@thunderbootyclap](https://get-help.theconstruct.ai/u/thunderbootyclap)\
**Post date:** [January 16, 2022, 4:51am UTC](https://get-help.theconstruct.ai/t/for-some-reason-my-task-3-wont-pass/14773/3 "2022-01-16T04:51:40Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![ralves](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/ralves/32/7039_2.png) [@ralves](https://get-help.theconstruct.ai/u/ralves)\
**Post date:** [January 17, 2022, 1:30pm UTC](https://get-help.theconstruct.ai/t/for-some-reason-my-task-3-wont-pass/14773/4 "2022-01-17T13:30:42Z")

</div>

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.

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

```

---

<div class="post-metadata">

**Author:** ![ralves](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/ralves/32/7039_2.png) [@ralves](https://get-help.theconstruct.ai/u/ralves)\
**Post date:** [January 17, 2022, 5:10pm UTC](https://get-help.theconstruct.ai/t/for-some-reason-my-task-3-wont-pass/14773/5 "2022-01-17T17:10:46Z")

</div>

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.

> [@Problems with task 1 and task 3](https://get-help.robotigniteacademy.com/t/problems-with-task-1-and-task-3/14521/8):
>
> Hi @ghduarte the possible reason why your script is failing is that what you are doing is: You are moving forward only when there are walls on both sides But what you have to do is: Keep moving until there are no walls detected on both sides. Your current script stops as soon as it passes the robot’s left wall, but the robot at this point has not yet gone through the robot’s right wall. Please check the expected behavior in the image below to understand what I mean here: [task3-The-Const…

---

<div class="post-metadata">

**Author:** ![thunderbootyclap](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/t/a4c791/32.png) [@thunderbootyclap](https://get-help.theconstruct.ai/u/thunderbootyclap)\
**Post date:** [January 19, 2022, 9:57pm UTC](https://get-help.theconstruct.ai/t/for-some-reason-my-task-3-wont-pass/14773/6 "2022-01-19T21:57:49Z")

</div>

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](https://stackoverflow.com/questions/54163163/python-while-with-two-conditions-and-or-or) post

---

<div class="post-metadata">

**Author:** ![ralves](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/ralves/32/7039_2.png) [@ralves](https://get-help.theconstruct.ai/u/ralves)\
**Post date:** [January 20, 2022, 1:09pm UTC](https://get-help.theconstruct.ai/t/for-some-reason-my-task-3-wont-pass/14773/7 "2022-01-20T13:09:50Z")

</div>


