I am fairly new to python, and was wondering whether anybody could help me with the following problem:
I am trying to map a Christmas tree after receiving an input from the user about the tree's height and base branch length. Here is the code I currently have:
tree_map_5 = ['B']
tree_map_4 = ['B']
tree_map_3 = ['B']
tree_map_2 = ['B']
tree_map_1 = ['B']
# (B means Bark (For the trunk))
Layers = int(input("\nHow many layers will your christmas tree have? (Maximum 5)\n\nInput: "))
Base_Branch_Length = int(input("\nHow long will the base branches of your tree be? (in centimetres)\n\nInput: "))
for i in range (Layers):
for j in range (Base_Branch_Length+1):
tree_map_'i'.append(0)
tree_map_'i'.insert(0, 0)
If the user were to say 5 layers and 5 base branch length, the lists would show this:
tree_map_5 = [0, 0, 0, 0, 0, B, 0, 0, 0, 0, 0]
tree_map_4 = [0, 0, 0, 0, 0, B, 0, 0, 0, 0, 0]
tree_map_3 = [0, 0, 0, 0, 0, B, 0, 0, 0, 0, 0]
tree_map_2 = [0, 0, 0, 0, 0, B, 0, 0, 0, 0, 0]
tree_map_1 = [0, 0, 0, 0, 0, B, 0, 0, 0, 0, 0]
I was wondering whether I would be able to write a for loop that adds noughts into a changeable number of lists (like I tried to do) depending on the number of layers they input.
Sorry if my question wasn't clear.
Thanks