jeudi 25 mai 2017

for loop never ends with a matrix

for sublistas in matriz:
for espacios in matriz:
    ran = random.choice([p_vivo, p_muerto])
    matriz.append(ran)

I am trying to with a matrix with 2 random choices: p_muerto or p_vivo The problem is, the loop never ends. I think it is because it keeps overwriting the elements of the matrix, so it keeps going indefinitely.

What can I do?




Aucun commentaire:

Enregistrer un commentaire