-1

So I am trying to create a new SEPARATE list every time a statement is true in python. Essentially:

for i in range(z):
    if X is true:
        create a new list

There is no way to know how many lists I need, I can try to estimate as I am doing a greedy type algorithm but I am struggling to figure out how iteratively make new separate lists.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241

1 Answers1

0

Try doing

myList = []
for i in range(z):
  if X is true:
    lis = []        
    #do something with lis
  myList.append(lis)

If you post exactly what you want to do after creating a new list, then a more efficient answer can be explained.. Based on the provided information, this is all I could come up with.

Swati Srivastava
  • 1,102
  • 1
  • 12
  • 18