Answer the question
In order to leave comments, you need to log in
How to find the number of columns in a python list?
I have two lists
first = [
['1', '2'],
['3', '4']
]
second = [
['1', '2', '3'],
['4', '5', '6']
]
Answer the question
In order to leave comments, you need to log in
The point is that what you showed is not a multidimensional array. It's just a list, each element of which contains the same list.
Why the question is not correct - well, try to answer the question, what should you get as a result if the list looks, for example, like this:
You can of course adapt len(ifirst), len(ifirst(0)),len(ifirst(1) ) and iterate further - you can recursively.
But if you really need arrays, then use numpy, and there is a .shape method directly intended to answer your question
ifirst=
Probably ...
print(max(list(map(len,second))))
The maximum of the number of elements will be displayed ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question