Where is my typo?

I’m getting an error on submit step 2 asking if the printed result is (diameter / 2)…

class Circle:
  pi = 3.14
  def __init__(self, diameter):
   print("Creating circle with diameter {d}".format(d=diameter))
    # Add assignment for self.radius here:
    self.radius = diameter / 2

But that only works when the instance method is above the print stament and referenced in the format statement.

class Circle:
  pi = 3.14
  def __init__(self, diameter):
   self.radius = diameter / 2
   print("Creating circle with diameter {d}".format(d=self.radius))
    # Add assignment for self.radius here:

What I’m a missing here?

1 Like

Hi,

Is the ‘radius’ of your ‘Circle’ objects half the passed in ‘diameter’ ?

yes :)! And still I can’t get past step 2. What am I doing wrong?

class Circle:
  pi = 3.14
  
  def __init__(self, diameter):
    print("Creating circle with diameter {d}".format(d=diameter))
    # Add assignment for self.radius here:
    self.radius = diameter / 2
    print(self.radius)
    
medium_pizza = Circle(12)
teaching_table = Circle(36)
round_room = Circle(11.46)

output:

Creating circle with diameter 12
6.0
Creating circle with diameter 36
18.0
Creating circle with diameter 11.46
5.73

What am I missing? Thanks in advance.

Regards,
Andreas

sadly your workaround doesn’t work for me :(.

I think it may be that you are using 11.46 instead of 11460 for the “round_table”

Also, you have “print(self.radius)” and it should be a “return” returns the formula for the circumference .