Square(side=9) got error

I don’t know how to get "Square(side=9)" return. I tried str and repr , but it give me error.
unindent does not match any outer indentation level

class Rectangle:
  def __init__(self, width, height):
    self.width = width
    self.height = height

  def set_height(self,height):
    self.height = height

  def set_width(self, width):
    self.width = width

  def get_area(self):
    return self.width * self.height

  def get_perimeter(self):
    return self.width + self.width * self.height + self.height

  def get_diagonal(self):
    return (self.width ** 2 + self.height ** 2) ** 0.5

  def get_picture(self):
    if self.width < 50 and self.height <50:
      shape = "*" * self.width 
      return shape * "\n" * self.height
    else:
      return "Too big for picture"

  def get_amount_inside(self, shape):
    return(self.get_area()//shape.get_area())

class Square(Rectangle):
  def __init__(self, side):
    Rectangle.width = side
    Rectangle.height = side

  def set_side(self, side_value):
    Rectangle.get_width(self,side_value)
    Rectangle.get_height(self,side_value)
  
 def __repr__(self):
   return f"Square(side={self.width})"

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66.

Challenge: Polygon Area Calculator

Link to the challenge:

Hello @nyanhtet89

Welcome to FCC
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

Thank you. Next time, I will be careful

I am not conversant with python but it seems you have an indentation error in the last method of square. Could it be the cause of your troubles?

1 Like

Yeah, that’s the one. Sorry I forgot to mention that in my question. This is my first question here so I left some informations.

If your issue is the indentation error then fixing it should work. Look at your code above and the one below after fixing it. Do you see any difference in the last def block?

class Square(Rectangle):
  def __init__(self, side):
    Rectangle.width = side
    Rectangle.height = side

  def set_side(self, side_value):
    Rectangle.get_width(self,side_value)
    Rectangle.get_height(self,side_value)
  
  def __repr__(self):
    return f"Square(side={self.width})"

I see, a space at the last def. Thank you. Still persist some error but the indentation is fixed. Thank you so much.

Yeah I noticed that. You need to brush up your OOP skills in python.

1 Like

I think so too. I have some difficulties writing extending OOP in second function. And still trying to understand how init function work.

1 Like