Skip to content

Instantly share code, notes, and snippets.

@naemazam
Created October 30, 2021 10:28
Show Gist options
  • Save naemazam/bfb73f0b152343922258980c4cbe719a to your computer and use it in GitHub Desktop.
Save naemazam/bfb73f0b152343922258980c4cbe719a to your computer and use it in GitHub Desktop.
# A basic code for matrix input from user
R = int(input("Enter the number of rows:"))
C = int(input("Enter the number of columns:"))
# Initialize matrix
matrix = []
print("Enter the entries rowwise:")
# For user input
for i in range(R): # A for loop for row entries
a =[]
for j in range(C): # A for loop for column entries
a.append(int(input()))
matrix.append(a)
# For printing the matrix
for i in range(R):
for j in range(C):
print(matrix[i][j], end = "")
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment