C1_W2_Linear_Regression_help_please

Can someone help me write this compute cost function i do have intermediate experience in writing code in python . As i understood i need to make a loop and compute W*x + B for every i and also the cost by subtracting y[i] from calculated value and squaring the whole term , and do this at the end of the loop total_cost = total_cost + cost , i cant fix the out of bound error in the loop someone please give me help in this so i know what level of code editing is required

def compute_cost(x, y, w, b):
“”"
Computes the cost function for linear regression.

Args:
    x (ndarray): Shape (m,) Input to the model (Population of cities) 
    y (ndarray): Shape (m,) Label (Actual profits for the cities)
    w, b (scalar): Parameters of the model

Returns
    total_cost (float): The cost of using w,b as the parameters for linear regression
           to fit the data points in x and y
"""
# number of training examples
m = x.shape[0] 

# You need to return this variable correctly
total_cost = 0

### START CODE HERE ##

Moderator edit, code removed.
## END CODE HERE ###

return total_cost

Please do not post your code on the forum. That is not allowed by the Code of Conduct.

Append is the wrong operation. You should add instead.