Adding brackets around a sequence of n length

I want to create sequences of n length depending on an input number.

In this example I have 3 input numbers [ 3, 2 ,0]
So I’d like output to read:
L[0] (1)
(2)
(3)

L[1] (1)
(2)

L[2] blank list

The sequences work fine and keep my list structure but I can’t seem to get the brackets to wrap without it doing weird things or flattening the list.

Hi @Alien

Your first code give you the output that you want?

No, it flattens the list when the brackets are added.

So, the output wouldn’t be like this?

Like this

image

I guess I got it. But the Empty List goes inside of the sublist 1 or out of it? What would be the output for something like this?

image

list [0]
(1)
(2)
(3)
(4)

List[1]
Empty list

List[2]
Empty list

List[3]
Empty list

So, have you any suggestions?

Actually, I’m kinda confused now haha.

1- Why list[0] starts at 0 and in the previous ones started at 1?

2- Why do the lists list[1], list[2] and list[3] are empty? I thought they were related to zeros, but in my examples there are only 2 zeros.

Heh, yea. I wrote that wrong…

Edited…

I want All I want is what I said in the first post :laughing:

I want the sequence as the output “seq” is giving. BUT with brackets round each number.

Like this?

def specific_output(lst):
	out = [[]]
	seq = []
	out.append([])
	for idx,itm in enumerate(lst):
		value = "(" + str(idx+1) + ")"
		out[0].append(value)
		out.append([]) if itm == 0  else seq.append(value)		
	out[1] = (seq)
	return out
	
OUT = specific_output(IN[0])