Login and get codingIn this Bite you have to complete
generate_improved_xmas_tree
that takes arows
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!
93 out of 96 users completed this Bite.
Will you be the 94th person to crack this Bite?
Resolution time: ~55 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 3.0 on a 1-10 difficulty scale.
» You can do it! 😌