def propagate(w, b, X, Y):
m = X.shape[1]
A = sigmoid(np.dot(w.T, X) + b)
cost = np.sum((( - np.log(A)) * Y + (-np.log(1 - A))*(1 - Y)) / (m)
dw = np.dot(X, (A-Y).T) / m
db = np.sum(A-Y)/ m
cost = np.squeeze(np.array(cost))
grads = {"dw": dw,
"db": db}
return grads, cost
output error →
File “”, line 42
dw = np.dot(X, (A-Y).T) / m
^
SyntaxError: invalid syntax
Check the brackets in the line upwards, cost, they dont match!
Sometimes it is confusing to me when to use matrix multiplication and when to use elementwise multiplication. I was using matrix multiplication to calculate the cost and I was getting inaccurate answers. I will reflect on my understanding. I know the difference is subtle 
Can you please specify for which codes line your question pertains to?
you can mention in your comment if the code is not part of any grader cell.
Regards
DP