Add one element of a list and the next

add one element of a list and the next


I can’t find the error.
Thanks.

you have a “while” statement on line 18 with nothing following it. That is the error that it is shown above the node. What exactly are you trying to do with this code?

2 Likes

@jesusricarte if it helps you can post in both Spanish and English; just put a break line in between the two, as I have done here.


Original post translated from English to Spanish provided below the line


@jesusricarte si te ayuda puedes publicar tanto en español como en inglés; simplemente ponga una línea de ruptura entre los dos, como lo he hecho aquí.

2 Likes

Hello, I’m not sure if this is what you’re trying to achieve.


Python script:

import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

espacio=IN[0]
listanumeros=IN[1]
listaX=[]
total=0
i=0
nb_element_3=listanumeros.count(3)
a=len(listanumeros)-1
while i<a:
    total=total+espacio+listanumeros[i]+listanumeros[i+1]
    listaX.append(total)
    i=i+1
OUT=nb_element_3,a,listaX

cordially
christian.stan

I want the 3 to be listNumbers.count

try replacing “while i <3:” with “while i < len(listaNumeros)-1:” Let me know if that is what you were looking for

1 Like

You may be confusing the count and len method. (I’m still learning about python)

Script Python
first_name='Jesus'

list_first_name=[i for i in first_name]

number_of_letter_s=list_first_name.count('s')

number_of_letters_composing_jesus=len(list_first_name)

OUT = list_first_name,number_of_letter_s,number_of_letters_composing_jesus

Cordially
christian.stan

OK… with len it was solved
thank you

2 Likes

thank you so much.

1 Like