Skip to content

Tag: python-3.x

How to create a matrix of lists?

I need to create a matrix MxN where every element of the matrix is a list of integers. I need a list so that I can append new elements as I go, therefore a 3D matrix would not work here. I’m not sure if what I need here would actually be a list of lists. Answer The following function creates

Retrieving error while accessing files from the folders

I have the following code I need to files from the folder to be read by opencv. I am retrieving the below error. Help is highly appreciated. Thanks Answer You’re iterating over a string, so it will only get the first character. You need to list the contents of the directory. Use os.listdir like this.