from operator import add
class Solution(object):
    def matrixReshape(self, nums, r, c):
        """
        :type nums: List[List[int]]
        :type r: int
        :type c: int
        :rtype: List[List[int]]
        """
        if len(nums) == 0:
            return nums
        origR = len(nums)
        origC = len(nums[0])
        if origR * origC != r * c:
            return nums
        oneline = reduce(add, nums)
        return map(list, zip(*([iter(oneline)] * c)))

Add py solution for 566. Reshape the Matrix
Add py solution for 566. Reshape the Matrix

566. Reshape the Matrix: https://leetcode.com/problems/reshape-the-matrix/
