Solution 1

``````def create_empty_box(height, width, char):
result = ''

if height < 3 or width < 3:
return "Invalid box dimensions"

# Build line for top/bottom of box
top_bottom_line = ''
for w in range(width):
top_bottom_line += char
top_bottom_line += '\n'

# Build line for middle of box
middle_line = ''
middle_line += char
for w in range(1, width - 1):
middle_line += ' '
middle_line += char
middle_line += '\n'

# Build top of box
result += top_bottom_line

# Build middle of box
for w in range(1, height -1):
result += middle_line

# Build bottom of box
result += top_bottom_line

return result``````

# Create Empty Box

Expand on the last assigment and write a function `create_empty_box` that takes three inputs: `height` (rows), `width` (columns), and a character `char` and creates a `height` × `width` box using the character `char` that only has characters on the borders of the box (it's not filled in).

If the box `height` or `width` are less than 3, return 'Invalid box dimensions' because it won't be an empty box.

Hint: Look for patterns in the the way the empty box looks when you design your solution (top to bottom, side to side).

``````>>> create_empty_box(3, 4, '*')
'****
*  *
****'
>>> create_empty_box(5, 5, '@')
'@@@@@
@   @
@   @
@   @
@@@@@'
>>> create_empty_box(1, 1, '\$')
'Invalid box dimensions'
``````

### Test Cases

test invalid box height -

``````def test_invalid_box_height():
assert create_empty_box(1, 4, 'Y') == "Invalid box dimensions"
``````

test a 5x8 box -

``````box_5x8_expected = """
xxxxxxxx
x      x
x      x
x      x
xxxxxxxx
""".lstrip()

def test_a_5x8_box():
assert create_empty_box(5, 8, 'x') == box_5x8_expected
``````

test a 3x4 box -

``````box_3x4_expected = """
****
*  *
****
""".lstrip()

def test_a_3x4_box():
assert create_empty_box(3, 4, '*') == box_3x4_expected
``````

test invalid box width -

``````def test_invalid_box_width():
assert create_empty_box(3, 1, '\$') == "Invalid box dimensions"
``````
def create_empty_box(height, width, char): pass