Different method in python 3
\nclass Solution:\n    def reconstructMatrix(self, upper: int, lower: int, colsum: List[int]) -> List[List[int]]:     \n        \n        sum=0\n        for i i
```\nclass Solution:\n    def reconstructMatrix(self, upper: int, lower: int, colsum: List[int]) -> List[List[int]]:     \n        \n        sum=0\n        for i in range(len(colsum)):\n            sum+=colsum[i]\n        if upper+lower!=sum:\n            return []\n        num_two = colsum.count(2)\n        \n        if num_two > lower or num_two > upper:\n            return []\n        \n        matrix=[[0 for i in range(len(colsum)) ]for j in range(2) ]\n        \n        \n        def insert(j,position,i,matrix,colsum):\n            if colsum[j]>0 and position>0:\n                    matrix[i][j]=1\n                    position-=1\n                    colsum[j]-=1\n            return j,position,matrix,colsum\n        \n        for j in range(len(colsum)):\n            if(upper<lower):\n                j,lower,matrix,colsum=insert(j,lower,1,matrix,colsum)\n                j,upper,matrix,colsum=insert(j,upper,0,matrix,colsum)\n            else:\n                j,upper,matrix,colsum=insert(j,upper,0,matrix,colsum)\n                j,lower,matrix,colsum=insert(j,lower,1,matrix,colsum)\n\n        return(matrix)\n```
['Python', 'Python3']