2D array element Calculation - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: 2D array element Calculation (/thread-2258.html) |
2D array element Calculation - poonck1 - Mar-02-2017 I have an array to do some calculation for each element, which looks like this: a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]My expected results is as follow after calculation: a_1 = [[2, 6, 3], [5, 12, 6], [8, 18, 9]] I wrote the following lines: f = 1 g = 2 a_1 = [c +f, (d+f)*g, e for (c, d, e) in array]However it is error message like this: How to amend the code to get the results I want? One more requirement is I don't want to use NumPy.
RE: 2D array element Calculation - wavic - Mar-02-2017 Hello! c_1 = [[c + f, (d + f)*g, e] for c, d, e in a]Post the full error traceback next time please |