Skip to content
Advertisement

Reading Matrix from file

I have a txt file consisting some numbers with space and I want to make it as three 4*4 matrixes in python. Each matrix is also divided with two symbols in the text file. The format of the txt file is like this:

JavaScript

My code is now like this but it is not showing the output I want.

JavaScript

Can you help me with that?

Advertisement

Answer

A good old pure python algorithm (assuming matrices can hold string values, otherwise, convert as required):

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement