I have python homework and is stuck on a question. It is called Height of plants and the description is: *There are n plants growing in a row. Their heights are given as input. In order to help the plants grow faster, farmer John will pull a subset of of plants up for a certain height every day. The subset of plants will be some plants that are consecutively aligned, and the whole process can be defined by three numbers, a, b, and c. John will pull plants from index a to index b (inclusive), and for each plant he will pull it up for height c. Given m days of John's plant pulling, please calculate the height of each of plant after m days.
*
**Additional information: **
*InputThe first line enters an integer n, representing the number of plants.
The second line enters n numbers, representing the initial height of each of the plants.
The third line enters an integer m, representing the total number of days that farmer John pulls up the plants
In the next m lines, each line enters three integers a,b,c, representing the range of plant a to plant b, and the height to pull c.
OutputOne line including n integers, separated by spaces, representing the final height of the plants.
Sample Input4
1 2 3 4
3
1 2 1
2 3 1
4 4 1
Sample Output2 4 4 5
*
I tried with this code:
def calculate_final_height(n, initial_heights, m, operations): final_heights = initial_heights.copy() for _ in range(m): for a, b, c in operations: for i in range(a-1, b): final_heights[i] += c return final_heights n = int(input()) initial_heights = list(map(int, input().split())) m = int(input()) operations = [list(map(int, input().split())) for _ in range(m)] result = calculate_final_height(n, initial_heights, m, operations) print(''.join(map(str, result)))
But it only said WRONG ANSWER. And when I use replit.com, it literally just bugs out and says a bunch of stuff you cannot ctrl C ctrl V. Help!