create square matrix python

Solutions on MaxInterview for create square matrix python by the best coders in the world

showing results for - "create square matrix python"
Ezio
27 Apr 2018
1R = int(input("Enter the number of rows:")) 
2C = int(input("Enter the number of columns:")) 
3  
4# Initialize matrix 
5matrix = [] 
6print("Enter the entries rowwise:") 
7  
8# For user input 
9for i in range(R):          # A for loop for row entries 
10    a =[] 
11    for j in range(C):      # A for loop for column entries 
12         a.append(int(input())) 
13    matrix.append(a) 
14  
15# For printing the matrix 
16for i in range(R): 
17    for j in range(C): 
18        print(matrix[i][j], end = " ") 
19    print()