Need help with "Defining Methods in a Class" challenge

# Write your Circle class here. This is my code.
class Circle:
    def __init__ (self, circle): = circle
    def radius (self, radius):
        self.radius = radius
    def area(self, radius):
        area = 3.14 * radius ** 2
    def circumference (self, radius):
        circumference = 2 * 3.14 * radius

I tried to figure out what is my error. The output of the problem is:

Traceback (most recent call last):
  File "", line 20, in <module>
AttributeError: 'Circle' object has no attribute 'change_radius'

The auto-filled code problem is:

if __name__ == '__main__':

    circle = Circle(7)

    keepgoing = True

    while keepgoing:

        radius = float(input("Circle radius: "))


        print("Area:", circle.area())

        print("Circumference:", circle.circumference())

        yn = input('Keep going? Y/N ')

        keepgoing = yn == 'y' or yn == 'Y'

And the problem say:

Write a Python class named Circle, constructed by a radius and two methods, which will calculate the circumference and the area of a circle. The script should ask for the user’s input for the radius, create a Circle object, and print out its area and circumference. It should ask for input again after it prints the area and circumference each time. Our aim here is to practice defining methods in a class.

The steps are as follows:

  1. Create a file named
  2. Define the Circle class and the Circle constructor method.
  3. Create the area calculation method, which returns the circle’s area.
  4. Create the circumference method, which returns the circle’s circumference.
  5. After the class definition, add the code that requests for user input for the radius.
  6. We’ll create a while loop so that the request for user input runs multiple times. In the while loop, we’ll request the user input, change the circle object’s radius, and then print out the area and circumference.
  7. You can run the script by using python The script will ask for input, calculate the area and circumference, print that out, and ask for your input again. The output should look as follows:


Thanks for reaching out! Your code is close! Making the following changes will make your code pass the challenge:

  1. Your radius function should be named change_radius so that Circle.change_radius will exist.
  2. Your area function should take self.radius instead of radius.
  3. Instead of using the number 3.14 as pi, you can use math.pi.

Your code should look something like the following:


class Circle:
    def __init__(self, radius):
        self.radius = radius

    def area(self):
        return math.pi * self.radius ** 2

    def circumference(self):
        return 2 * math.pi * self.radius

    def change_radius(self, new_radius):
        self.radius = new_radius

Let me know if this helps!