import random
M = 4
N = 3
def generisanjevol1(nekalista, m):
return random.choices(nekalista, k=m)
def generisanjevol2(nekalista, m,n):
#obj = [[random.choice(nekalista,k=m)] for i in range(N)]]
obj = [[random.choice(nekalista)] for i in range(n)]
return obj
#def poredjenje()
listaslova = ['A', 'B', 'C', 'D', 'E']
lista = generisanjevol1(listaslova, M)
lista2 = generisanjevol2(listaslova, M, N)
print(lista)
print(lista2)
So above is my try (generisanjevol2(nekalista, m,n)...
What I am trying to do is next:
I want to generate N of arrays and fill them with strings which are generated by random.choice function and they still must be strings from listaslova)
Perhaps let's say N=3 (N represents numbers of arrays) and M=4 (M represents length of array) I should get something like this (doesn't have to be same data in arrays, because of course they are randomly generated):
[A,C,D,E]
([A,C,E,D] [E,C,B,A] [E,D,D,A])
But the results which I get are following:
[A,D,E,C]
[[B],[D],[E]]
P.S If I try the one which is commented I get an error