Iterative grow a shuffled list in python
I am trying to iteratively shuffle a list of 4 elements, then append the shuffled list to a growing list. The result will be a list that is some multiple of 4 elements long, with every four elements being some combination of my original list.
My code is
import random list1 = ['X','Y','Z','Q'] list2 =  for drop in range(0,72/4): random.shuffle(list1) list2.append(list1)
The problem that I seem to have is that list2 will be the same shuffled version of list1 over and over.
Example list2: ['Q','X',Z','Y','Q','X',Z','Y','Q','X',Z','Y',...]
I think you wanted to write
Otherwise, you would add the same instance of the object list1 to list2 over and over again.