I have this code wrote in python,used to input a matrix:
def gestionmatrice():
print("Entrez la matrice,séparé par des espaces pour chaques colonnes")
print("une rangée par ligne,et faites un ligne vide pour terminer")
matrix = []
while True:
line = input()
if not line: break
values = line.split()
row = [int(value) for value in values]
matrix.append(row)
print(matrix)
The user input the matrix by entering all desired int value per row separated by a space,then press enter to confirm the row and input the next one. To finish, user have to input a blank row and press enter. At the end,I want to see the matrix by printing it; the problem is that it doesn't work correctly; if for example the user input 1 2 3 and then 4 5 6 on the next row, the print(matrix) will result as:[[1, 2, 3], [4, 5, 6]].It would be supposed to print 1 2 3
4 5 6 so something doesn't work.What has to be modified? Thanks in advance.
10? Do you want everything to be aligned?