-3
I want to read matrix by placing the commas to separate the numbers, but when I ask to show the matrix, it gives this error:
<generator object <genexpr>
That never happened to me, I have no idea how to regularize. Follow the code below:
leia =input('Digite a dimensão da matriz: ')
vet = [float (x) for x in leia.split(',')]
matriz = []
for i in range (len(vet)):
linha =[]
linha.append(float(x) for x in input(f'Digite a linha {i}: ').split(','))
matriz.append(linha)
print('Matriz digitada:')
for linha in matriz:
print(linha)
read =input('Enter matrix dimension: ') vet = [float (x) for x in leia.split(',')] matrix = [] for i in range (Len(vet)): line =[] line.append(float(x) for x in input(f'Enter line {i}: '). split(',')) matrix.append(line) print('Typed matrix:') for line in matrix: print(line)
– Garota de Programa
Change the line
linha.append(float(x) for x in input(f'Digite a linha {i}: ').split(','))
forlinha.extend(float(x) for x in input(f'Digite a linha {i}: ').split(','))
– Augusto Vasques