While Loop not Processing Last Item

This bit of DS doesn’t seem to process the last item in the list. Not sure what’s wrong… thoughts?

 count = List.Count(thingsInTheModel);
 return = [Imperative]
 	while (count>0)
 	    ("do several things called under other def code blocks and report a variableNumber")
 return =  (some result)

Hi @Greg_McDowell
try while (count>=0)

I thought that did the trick at first… but then I changed somethings, saved, and now it’s not working anymore! Argh.

One thing odd I noticed right away was that a counter I had in the loop returned a number in the thousands rather than what it should have been; just 3.

How does a script function if a part of the while-loop performs an action but returns a null? This is the more complete DS (minus the other defs);

def ViewsToSheets(sheetName:var[],sheetNumber:var[],
i = 0;
numberViews = List.Count(views);
count = List.Count(views);
return = [Imperative]
	while (count>=0)
        //gets value of "Sheet Number" parameter of views, compares to current sheetNumber, counts number of views that match 
        //increments alphanumeric sheet number by 1
		i = i+1;
	return=(numberViews) + " views placed on " + (i) + " sheets.";

I know that the Sheet.ByNameNumberTitleBlockAndViews node returns a null if you feed it more views that will fit on the sheet (what this DS is trying to resolve) but it does create the sheet and place the views. Just noT sure how the null might be impacting things.

So, I’ve got it back to working with count>=0 but it still runs through it several thousand times. If I follow along with the logic I can see why, sort of.

After the number times it should run through if I set count>0, count starts to equal 0 and thus the result is always true and the while-loop continues. It seems like it should continue on to infinity but it stops after about 6-8,000 runs through the loop. Sometimes it does seem to run forever, or at least so much longer than other times that I eventually force Dynamo to close. When it does run it takes a lot longer than when count>0 even though it’s only doing the set of actions 1 more time.

Perhaps there’s another approach to managing the last item when count>0. Can I send the results of the while-loop (a set of views, and the sheet number) to another process?