I am using jupyter notebook. I want to print a simple integer matrix in the general form, i.e., I eant the output to be like this: a[0][0] = 1 a[0][1] = 2 a[1][0] = 3 a[1][1] = 4
Here's my program:
column = int(input("Enter the number of columns: "))
row = int (input("Enter the number of rows: "))
a=[[0 for x in range(column)] for y in range(row)]
for i in range (0, row):
for j in range (0, column):
a[i][j]=int(input(" Enter the elements: "))
for i in range (0, row):
for j in range (0, column):
print ("a[",i,"][",j,"] =",a[i][j],"\t",),
print ("\n")
But I get the output as:
Enter the number of columns: 2
Enter the number of rows: 2
Enter the elements: 1
Enter the elements: 2
Enter the elements: 3
Enter the elements: 4
a[ 0 ][ 0 ] = 1
a[ 0 ][ 1 ] = 2
a[ 1 ][ 0 ] = 3
a[ 1 ][ 1 ] = 4
The print(), function in the loop goes to a new line even though I have put a comma after it. Please help me get the desired output format. Thank you.