In your question, it is not very clear what data types are used and, apparently, they are using some kind of non-traditional type of recursion (possibly as part of a class). To scroll scroll down a bit.
I took the liberty of changing the code a bit and using the regular random library, so what you are looking for might look like
import random
We stop recursion in one list of elements and apply recursion further, if we have not stopped using a random index, pulled out a possible range (note that random.randint generates an index with the specified boundaries).
Your error does not use any concatenation operator between the two parts of the return value.
[A][B] does not merge both lists, but tries to index the list specified in B (in your case) from A , which is an incorrect use of the type.
Therefore, you can resort to the original function (with obsolete numpy random) as
def split_list(l): if l.__len__() > 2: pivot = np.random.random_integers(0, l.__len__() - 1) l = [RandomTree.split_list(l[:pivot])] + [RandomTree.split_list(l[pivot:])] return l
Uriel source share