Create a gh like series with Python?

python
unhandled

#1

Hi everyone,

I was wondering how one could define a function similar to the Series in grasshopper, with (Start, Step, Count).
Most of the things I have searched online make use of a while loop or range function, but in this way you cannot control the exact amount of items that you want in the list…

Thanks for any insight


#2

What about this?

start = 0
step = 1
count = 10

values = [start + (c * step) for c in range(count)]
print(values)

#3

Thank you Mostapha, that was it!


#4

I think range(Start,Count*Step,Step) alone might do it.

Edit: It does:

2018-08-10%2013_49_16-Grasshopper%20-%20unnamed


#5

Could it that when you change the step it stops working? Or am I doing something wrong?


#6

Ah yes, no I forgot to add the Start value parameter to the range() stop parameter:

Doh!