<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>I would like to know how I could use the insert method in a List matrix eg. for the matrix below<br><br>M=[[1,2,3], [3,2,1], [4,3,2]]<br><br>if wanted to insert the string 'pod' in list [0] before [1] in list [0] in M using the built in method insert How would I go about doing this? I've tried may List Comprehension possibilities but none of then worked. Below are some of the things I tried. <br><br>>>> M=[[1,2,3], [3,2,1], [4,3,2]]<br>>>> M.insert([1][1], 'pod')<br><br>Traceback (most recent call last):<br> File "<pyshell#19>", line 1, in <module><br> M.insert([1][1], 'pod')<br>IndexError: list index out of range<br>>>> [row[0] for row in M.insert(1, 'pod')]<br><br>Traceback (most recent call last):<br> File
"<pyshell#20>", line 1, in <module><br> [row[0] for row in M.insert(1, 'pod')]<br>TypeError: 'NoneType' object is not iterable<br>>>> M.insert(1,'pod')<br>>>> M<br>[[1, 2, 3], 'pod', 'pod', [3, 2, 1], [4, 3, 2]]<br>>>> M.insert[0](1,'pod')<br><br>Traceback (most recent call last):<br> File "<pyshell#23>", line 1, in <module><br> M.insert[0](1,'pod')<br>TypeError: 'builtin_function_or_method' object is unsubscriptable<br><br><br>Any help is greatly appreciated! Thanks!<br><br>-Raj<br></div></div><br>
</body></html>