Hello,
for any reason it does not work either dynamo or python
nums = IN[0]
top = []
for i in nums:
top.append(i[0:2])
OUT = top
just want the first index the last 3 characters
KR
Andreas
Hello,
for any reason it does not work either dynamo or python
nums = IN[0]
top = []
for i in nums:
top.append(i[0:2])
OUT = top
just want the first index the last 3 characters
KR
Andreas
hello
a=IN[0]
OUT = a[len(a)-3:]
cordially
christian.stan
how to implement it in a for loop?
nums = IN[0]
top = []
for i in nums:
top.append(i[len(i)-3:])
OUT = top
i got an error
Some of your values are nulls. Yes, you’ll have to deal with those separately. Either remove them, skip them, or replace them with something else. (And as an FYI, you can just use i[-3:] instead of calculating i[len-3:] since indexing already allows negative values.)
If you want to use nodes, you need to focus on what you can do equally to all items. Your strings have different lengths, so you can’t remove the same number of characters and be left with the same lengths. You need to get the specific substring instead.
nums = IN[0]
top = []
for i in nums:
top.append(int(str(i)[len(str(i))-3:]))
OUT = top
too late
edit: with remark from Mr. Nick (Thank you for the always wise advice:
) and as your first data is not a number, it is better to leave it as a text string
for i in nums:
top.append(str(i)[-3:])
cordially
christian.stan