← Back to challenges

Christmas Tree

PythonHardformattingstrings

Instructions

Write a function to create a Christmas tree based on height h.

Examples

tree(1) ➞ [
  "#"
]

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

tree(5) ➞ [
  "    #    ",
  "   ###   ",
  "  #####  ",
  " ####### ",
  "#########"
]

tree(0) ➞ []

Notes

N/A

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