Grasshopper Python - Tuple must be string or a number, how to make a tuple one?

Tuple must be string or a number, how to make a tuple one?

20180912 00 problem (9.6 KB)

indexNumber is the tuple, you should specify the index of the item from this list.

list = tuple (not exactly but yeah it is)

1 Like

Ah thank you!

Somehow it does not do the trick completely. The output of C has to be a list of (9 + 0), (9 + 64), etc. It does not have that outcome.

Trying to make the typle a list does also not work.
b = list([sum(i) for i in a])

20180912 01 problem (11.9 KB)

I still cannot get my head around it.

if it must be a list then you would have to iterate, calculate over all of indexNumber items.

c=[] #declare c as list
for i in range(len(indexNumber)+1): # not sure about the +1 you'll have to test it
    # iterate c with all values from indexNumber

I don’t know what for indexNumber is enumerate(b) is for, I feel uncomfortable with IFs and FORs placed in the row after definition of a variable. I don’t have much experience in coding and I don’t know how to use such declarations.

I believe what you want to add is not an index…
indexNumber is obviously integer so you don’t need int() but I guess you want to add something else which is supposed to be not an integer and that’s why you need int()…

Jumping to the the point, I think this is what you wanted to do.
c=[indexPoint + int(num) for (index,num) in enumerate(b)]
But, if you don’t need index, you don’t need enumerate.
So, the code is further reduced to,
c=[indexPoint + int(num) for num in b]

The same thing can be done by map():
c=map(lambda num:int(num)+indexPoint,b)