Tuesday, 3 September 2013

Subtracting a value from all elements of a 2D list in python

Subtracting a value from all elements of a 2D list in python

I have a 2D list and I want to subtract a floating point value from all
the elements of the 2D list:
mat = [[1, 2], [3, 4]]
cons = 13
mat1 = cons - mat
But the last line doesn't work. How to do this in a 2D list in python?
Thank you.

No comments:

Post a Comment