Sparse Matrix Program In Python Using Loop