Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 12 Rectangle class #37

Open
Jaro266613 opened this issue Jun 10, 2021 · 1 comment
Open

Chapter 12 Rectangle class #37

Jaro266613 opened this issue Jun 10, 2021 · 1 comment

Comments

@Jaro266613
Copy link

class Rectangle():
def _init(self, w, l):
self.width = w
self.len = l

def area(self):
    return self.width * self.len

def change_size(self, w, l):
    self.width = w
    self.len = l

rectangle = Rectangle(10, 20)
print(rectangle.area())
rectangle.change_size(20, 40)
print(rectangle.area())


TypeError Traceback (most recent call last)
in
----> 1 rectangle = Rectangle(10, 20)
2 print(rectangle.area())
3 rectangle.change_size(20, 40)
4 print(rectangle.area())

TypeError: Rectangle() takes no arguments

@Pranshu1902
Copy link

you missed the "__" in the initialization of Rectangle class. It should be "init" but it is written as "__init"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants