Why is my Triangle class not accepted?


Why is my Triangle class not accepted?


Here are a few common mistakes when creating the Triangle class and how to fix them:

  1. Forgetting to indent your code to be inside of the class Triangle code block – be sure to indent using 2 spaces per indentation level
  2. Not initializing the self.variable values with the arguments passed to the __init__() method
  3. Typos! Python has no way of knowing what you’re referring to unless you spell things exactly as they were spelled elsewhere, so keep a close eye on spelling, capitalization, and punctuation.

2 posts were split to a new topic: Do you at CodeAcademy analyse the kind of mistakes we do?

def Triangle(object):
  def __init__(self, angle1, angle2, angle3):
    self.angle1 = angle1
    self.angle2 = angle2
    self.angle3 = angle3
my_tri = Triangle(2,3,4)

Here is my code for this exercise. The compiler throws an errror. It says Triangle() takes only one argument even though I’ve made it with three other arguments. I’ve checked previous code in the lesson, and formatted mine the same way. What is wrong?

In your first line you wrote “def” instead of “class”, the rest looks good to me