Tried improving the code in Hint, but it doesn't work. For some reason



<Below this line, add a link to the EXACT exercise that you are stuck at.>

Not stuck tho.

<In what way does your code behave incorrectly? Include ALL error messages.>

Interpreter returns none, I get a message that says “Oops, try again. It looks like your check_angles method doesn’t return True for valid triangle angle values.”

<What do you expect to happen instead?>

I expected the if statement to return true if given any number of arguments that sum up to three. Although it’s supposed to be a triangle, so this isn’t ideal, but still. Is manually typing angle1+angle2+angle3 the only way to do that? It sort of looks clumsy.

class Triangle(object):
    def __init__(self, angle1, angle2, angle3):
    def check_angles(self, *args):
        if sum(args)==180:
            return True
            return False


It’s best to stick to what the instructions asked you to do (manually adding them). :slight_smile: If you want to try doing it a different way, you can copy your code and experiment with it in a code editor.
Also, you may want to reread the instructions again, did you create your objects like they asked?


I actually already completed the whole Classes lesson and I am just left with input/output. I just like to experiment because that’s how I learn. So again, why doesn’t *args work? How would I handle multiple inputs (10, 20, hundreds of them?) I wouldn’t just type them in manually.


This method only takes one parameter, self. Use the __init__ method to pass your arguments.

From a purist point of view, splat is not very reader friendly and actually discouraged in style guides. Better that the arguments were in a list or tuple and unpacked by the function (if there are to be many of them). That way the list can be inspected while debugging.

Here is an example…

  def __init__(self, *args):
    self.angle1 = args[1]
    self.angle2 = args[2]
    self.angle3 = args[3]


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.