Inserting elements to a list in Python

I have a list Cb. I want to insert element 0 at len(Cb[0]) but I am getting an error. I present the expected output.

Cb=[[1.0, 0.0, 0.0]] 

for i in range(0,len(Cb[0])):
    Cb=Cb[0].insert(0,len(Cb[0])) 
print(Cb)

The error is

in <module>
    Cb=Cb[0].insert(0,len(Cb[0]))

TypeError: 'NoneType' object is not subscriptable

The expected output is

[[1.0, 0.0, 0.0, 0.0]]


Comments

Popular posts from this blog

I get wrong characters when retreiving the message body of an email using TIdIMAP4.UIDRetrieveTextPeek2()

How to drop the all the 1's in a correlation matrix

Today Walkin 14th-Sept