Sequence list

I am trying to sequence the list with a to z. I need a list like A1a, A2a, A4a, A4b, etc. I guess I am using a wrong level. how do set the lists to the right level? thanks.

Hello
an example with Python

import sys
import clr

start = ord('a')
lstNumber = IN[0]
out = []
purgelst = sorted(list(set(lstNumber)), key = lambda x : lstNumber.index(x))

for i in purgelst:
	for j in range(lstNumber.count(i)):
		out.append(i + chr(start + j))

OUT = out
2 Likes

EDIT: I misread your initial problem, so the explanation below isn’t actually what you’re looking for but the information still might be helpful.

You’re not using any list levels in your example. List levels refers to the level of the list you’re specifying for a given input, not the structure of the list (although that can sometimes have a similar effect.)

In the example below, the + node shows you what I’m talking about. The list level for the x input is set to @L1. This means that each item at level one in that list will be treated as its own input. The code block shows how to use list levels with DesignScript.

2 Likes

@ka-wai.liu9ECQM

3 Likes

@AmolShah beat me to it, but you can also just get the count for each item and step through your letters that many times.

4 Likes

@Nick_Boyts I was planning to do something just like that and I thought what would @Vikram_Subbaiah do here? Just read his articles on replication guide and wanted to use it somewhere!

2 Likes

Hi @Nick_Boyts ,

Why would you want to add another node (the List.Count), if you don’t actually need it according to the solution of AmolShah?

(Just curious :smiley: )

Fair question. Most of the time you wouldn’t. However, since this is mainly an educational forum, I wanted to show a simple way that (to me anyway) is easier to understand than just hoping that list levels works out. The best solution is always the one you’re most comfortable with, and sometimes that means using more nodes. There’s a reason most of us don’t just use a single giant code block of DS like Vikram. :grin:

5 Likes

Doing so demonstrates better understanding of the workflow and gives better control over the output.

On the contrary DS code for most tasks are actually succinct :nerd_face:
The giant ones perform tasks which would otherwise require miles of spaghetti connecting hundreds of nodes (and sometimes not possible with just nodes).

2 Likes