fork download
  1. def mult(matrix, n):
  2. return [[element * n for element in line] for line in matrix]
  3.  
  4.  
  5. matrix = [
  6. [1, 2, 3],
  7. [4, 5, 6],
  8. [7, 8, 9]
  9. ]
  10.  
  11. print(mult(matrix, 5))
  12.  
Success #stdin #stdout 0.03s 9336KB
stdin
Standard input is empty
stdout
[[5, 10, 15], [20, 25, 30], [35, 40, 45]]