← Back to challenges

Making a Box 2.0!

PythonHardvalidationformatting

Instructions

This is based on Helen Yu's Making a Box challenge. This challenge is the same execpt that instead of a list of strings, your function should output a matrix of characters.

Examples

char_box(1) ➞ [
  ["#"]
]

char_box(4) ➞ [
  ["#", "#", "#", "#"],
  ["#", " ", " ", "#"],
  ["#", " ", " ", "#"],
  ["#", "#", "#", "#"]
]

char_box(2) ➞ [
  ["#", "#"],
  ["#", "#"]
]

Notes

As an added bonus, try making char_box(0) output [[]] and make any strings, non-integers, and negative numbers output -1.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.