Using code block to number panels not working

I have a list of numbers containing 0,1,2, and I created a function to create a number range for the list
where the list contains 0 - no number should exist
where the list contains 1 - the number goes up by 1
where the list contains 2 - the number goes up by 2
but for some reason, the script is not working.
Any one has an idea why?

I prefer to use Python. It allows you to create a range based on n values much easier.

out = []
n = 1
for i in IN[0]:
	if i == 1:
		out.append("G"+str(n))
		n = n+1
	elif i == 2:
		out.append("G"+str(n)+"-G"+str(n+1))
		n = n+2
	else:
		out.append("")
OUT = out
out = []
n = 1
for i in IN[0]:
	if i == 0:
		out.append("")
	else:
		strings = []
		for nums in range(n,n+i):
			strings.append("G"+str(nums))
		out.append("-".join(strings))
		n = n+i
OUT = out

@michalz I think it’s related to this bug:

there is a workaround provided at the end of the thread.