0
How to do matrix input in python
Using any way
2 Answers
+ 4
>>> lst = list(range(-10,21,5))
>>> lst
[-10, -5, 0, 5, 10, 15, 20]
fills a list lst with numbres from -10 up to 20 with numbers in step of 5
>>> lst.append('a, b, c')
>>> lst
[-10, -5, 0, 5, 10, 15, 20, 'a, b, c']
appends 3 new elements
>>> lst.insert(2, 'XX')
>>> lst
[-10, -5, 'XX', 0, 5, 10, 15, 20, 'a, b, c']
inserts a new element at index 2
>>> lst[4] = 55
>>> lst
[-10, -5, 'XX', 0, 55, 10, 15, 20, 'a, b, c']
list element with index 4 will be peplaced with 55
>>> lst.remove(20)
>>> lst
[-10, -5, 'XX', 0, 55, 10, 15, 'a, b, c']
list element "20" will be removed
0
rows of 3
n = [int(i) for i in input().split()]
matrix = [n[i:i+3] for i in range(0,len(n),3)]