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
Post a Comment