+ 1

Matrix in python

I want to collect all elements of a matrix in a list or in a tuple.what i do?

23rd Nov 2020, 10:05 PM
Mohammad
Mohammad - avatar
5 Respostas
+ 2
There are other ways to do this, so I'll keep it very simple for now. This code will work to flatten a 2D list or matrix only. https://code.sololearn.com/cVahrjLtqevH/?ref=app
23rd Nov 2020, 10:53 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
If you have a X by Y matrix and you are wanting to flatten it so that it is a linear list. You can achieve this by simply looping over each sub list in the matrix and appending them to a new list.
23rd Nov 2020, 10:28 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Thank you very much
23rd Nov 2020, 10:55 PM
Mohammad
Mohammad - avatar
+ 1
23rd Nov 2020, 11:26 PM
Per Bratthammar
Per Bratthammar - avatar
0
Sorry,i dont understand because i am a elementary programmer. Can you coding an example?
23rd Nov 2020, 10:43 PM
Mohammad
Mohammad - avatar