Polygon Area Calculator display

So, I am tackling this one:

class Rectangle:
  def __init__(self, width, height):
    self.width = width
    self.height = height
  def get_picture(self):
    a = ""
    if self.width >= 50 or self.height >= 50:
      print("Too big for picture.")
    else:
      for i in range(self.width):
        a += "*"
      for j in range(self.height):
        print(a + "\n")
   
R1 = Rectangle(5,4)

print(R1.get_picture())

It draws the piucture but at the end a line with None is displayed:

*****

*****

*****

*****

None

I am chasing my tail trying to figure it out… I haven’t tried this at the repl so no link to that yet… Can someone please tell me what am I doing wrong?

In Python, if a function does not explicitly return a value (which your get_picture method does not), the value None is returned by default. Inside get_picture you should be creating a string to return instead of using print to display the string.

1 Like

Yeah, it worked… Just finished it with your suggestion…