

def sum_matrix(n):
    """ Returns a sum of all elements in a
    given matrix """
    p = [sum(x) for x in n]
    print (len(p))
    return sum(p)


if __name__ == '__main__':
    print (sum_matrix([[0, 3, 0], [0, 4, 0], [0, 13, 0]]))



def sum_matrix(n):
    """ Returns a sum of all elements in a
    given matrix """
    
    return sum([sum(x) for x in n])


if __name__ == '__main__':
    print (sum_matrix([[0, 3, 0], [0, 4, 0], [0, 13, 0]]))

Make it look more pythonic
Make it look more pythonic

  
  
  def sum_matrix(n):
      """ Returns a sum of all elements in a
      given matrix """
+     
+     return sum([sum(x) for x in n])
-     p = [sum(x) for x in n]
-     print (len(p))
-     return sum(p)
  
  
  if __name__ == '__main__':
      print (sum_matrix([[0, 3, 0], [0, 4, 0], [0, 13, 0]]))
  
Make it look more pythonic
## Code Before:


def sum_matrix(n):
    """ Returns a sum of all elements in a
    given matrix """
    p = [sum(x) for x in n]
    print (len(p))
    return sum(p)


if __name__ == '__main__':
    print (sum_matrix([[0, 3, 0], [0, 4, 0], [0, 13, 0]]))

## Instruction:
Make it look more pythonic
## Code After:


def sum_matrix(n):
    """ Returns a sum of all elements in a
    given matrix """
    
    return sum([sum(x) for x in n])


if __name__ == '__main__':
    print (sum_matrix([[0, 3, 0], [0, 4, 0], [0, 13, 0]]))
