I have an 2D array to do some calculation for each element, which in this format:
a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
My expected results is as follow after calculation:
a_new = [[2, 6, 3], [5, 12, 6], [8, 18, 9]]
I wrote the following codes:
f = 1
g = 2
a_1 = [c +f, (d+f)*g, e for (c, d, e) in array] #I expect this can bring the results to form the format I want.
However, it has the error message:
SyntaxError: invalid syntax
How to amend the code to get the results I wanted? And also I don't want to import and use NumPy for doing calculation.