+ 1

Can you give me a sample python code to accept and print values of a matrix using lists.

4th Nov 2018, 2:34 PM
Mara
5 odpowiedzi
+ 2
OK for printing a list you can use this method: https://code.sololearn.com/c3fiXhcCM0x9/?ref=app Why use join? to get rid off square brackets and commas in printing output Remember to use map with the list elements are not str type. But we are talking about matrix. So you can use a for-each to iterate line by line and print with same method likes this: https://code.sololearn.com/cDM5ajLc7KDo/?ref=app
4th Nov 2018, 2:54 PM
Anya
Anya - avatar
0
What kind of matrix?
4th Nov 2018, 2:43 PM
HonFu
HonFu - avatar
0
a matrix made-up of numbers
4th Nov 2018, 6:15 PM
Mara
0
@shivaani i think HonFu is asking with is a 2d matrix or 3d.
4th Nov 2018, 6:19 PM
Anya
Anya - avatar
0
The way I used so far in Python is one-dimensional lists that are interpreted two- or three-dimensionally by slicing. Maybe I should quickly clarify that: If you have a list like rect = [0, 1, 2, 3, 4, 5, 6, 7] and you want to read it vertically, you can write (example for first column) print(rect[0::4]) using the slice's 'step' part. https://code.sololearn.com/c36892iW8Srd/?ref=app https://code.sololearn.com/cJPmTf5bW1la/?ref=app https://code.sololearn.com/cOgBIKfp377h/?ref=app
4th Nov 2018, 6:21 PM
HonFu
HonFu - avatar