Class Basics, 15/18


#1

Code entered: (copy paste!)

def Triangle(object):
  def __init__(self, angle1, angle2, angle3):
    self.angle1 = angle1
    self.angle2 = angle2
    self.angle3 = angle3

Gives error “Did you set your init() method to take four arguments: self, angle1, angle2, and angle3?” while running it in IDLE, or Spyder there is no error at all.

Finally when i gave up and asked for the code, this is what I get (also copy & paste):

class Triangle(object):
  def __init__(self, angle1, angle2, angle3):
    self.angle1 = angle1
    self.angle2 = angle2
    self.angle3 = angle3

And it does not pass neither (I can choose ‘Next’ so I’m not really blocked)


#2

you made a function named Triangle, not a class. That is the differences between the codes

what you got, should pass the exercise?


#3

Oeps, by checking if syntax was correct in Spyder I clearly overlooked this. Thx


#4

all the code within both code samples uses correct syntax, however some mistakes use correct syntax, but are still wrong. You can’t rely fully on tools like Spyder.

Any further questions?


#5

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