Organizing a list with a sequence

Hello everyone,
How can I sort a list in which it is taking two index and adding them to another list with a sequence, I want add them in a way that it takes two index at a time then remove the other index in the new list and take the next one , I couldn’t explain it by writing so there is a simple example to illustrate my purpose.
The blue List is the list I want to achieve , you can see that I want A,B to be with number1 , Then B & C with number 2 , then C &D With Number 3, IS there anyway I can achieve that ?
Thanks a lot

1 Like

here you are:

list = IN[0]
seq = IN[1]

result = []
for i,s in enumerate(seq):
	temp = [s,list[i], list[i+1]]
	result.append(temp)
	
OUT = result
3 Likes

Hi newshunhk , Thanks A lot dear this is the way I want it exactly , but forgive me I don’t know how to insert a python script may I ask how did you get this Black screen that says python script ?

@ahmadkhalaf7892 ,


Thats not flexible … i realy do indexing the values! maybe it helps

1 Like

Hi, right click on the node:

image

hello

cordially
christian.stan

2 Likes

@christian.stan ,

:slight_smile: that looks very easy!

1 Like

Hello
I learn a lot of python with the posted messages
too
it’s good, I’m making progress. :wink:

Cordially
christian.stan

1 Like

Thanks a lot Andreas this one also works but my script is way to big for now so I am trying to limit my nodes , again thanks a lot

2 Likes

Hi Christian this also works I tried this approach but I only have 1 , 2 , 3 as strings for example and A, B, C D , in the case you provided me I was always getting an E letter added out of no were do you for example how can we remove , it’s just out of knowledge I am trying learn as much as I can
Thanks

2 Likes

Hi Newshunhk how can I make the script work for 3 lists if I may ask ?

Hey draxl, how can i convert my theme black like you?

you mean this?

list1 = IN[0]
list2 = IN[1]
seq = IN[2]

result = []
for i,s in enumerate(seq):
	try:
		temp = [s,list1[i], list1[i+1], list2[i], list2[i+1]]
		result.append(temp)
	except:
		pass
	
OUT = result
1 Like

It is the default color from revit 2023.

1 Like

To answer your question about retrieving the number of lists
here is

Cordially
christian.stan


Hi Again,
I mean that When I Have 3 lists it is only taking two and not adding The 3rd list into the script, I would only have two lists

I will try this now Christian ,
Thanks a lot man

1 Like

Christian ,
My problem here is that two lists have 2 indexes and one list have 3 indexes maybe this would help you


Hi Newshunhk I don’t know if this would help , But I have a list with 3 index and two lists with 2 indexes I want to join the lists with the sequence, like before

can you show more on the left? see what are you feeding.