Xmas tree 2.0
Level: Intermediate (score: 3)
In this Bite you have to complete generate_improved_xmas_tree
that takes a rows
arg (= number of rows with leafs). For each row you add a star, leafs and a trunk and center them nicely. This bite is an extension to Bite 119 with additional elements and some twists.
Elements of the tree:
STAR
: Every tree has exactly one star at the top row.LEAF
: Every tree hasrow_number * 2 - 1
leafs per row.TRUNK
: Every tree has a trunk with a height of 2 and a width which is half of the largest leaf row.
However, the trunk should always be nicely centered by having the same number of empty spaces on both sides of the trunk. Therefore, you have to consider the width of the leaf rows and do some conditional rounding :)
The tree with default args should look like this:
+ * *** ***** ******* ********* *********** ************* *************** ***************** ******************* ||||||||||| |||||||||||
Return the finished tree as a multi-line string (use newlines \n
between the lines).
Good luck and keep calm and merry Python Xmas!