I need to print a rectangle using the str method in a class
I tried writing a function that prints the rectangle and returning it from str using f string:
def pprint(self):
"""prints a rectangle using '#'"""
for height in range(self.__height):
for width in range(self.__width):
print('#', end='')
print()
def __str__(self):
"""prints a rectangle using '#'"""
return f"{self.pprint()}"
but in output I get None on the next line:
test code:
my_rectangle.width = 10
my_rectangle.height = 3
print(my_rectangle)
Output:
##########
##########
##########
None