# Python problem with fRange floating values

Why does a 2.3333 appears? It should end at 2.0.

The goal is to set a size of x and y; and that within the size a resolution can be set wherein the size does not change, only the amount of points within the size as like a resolution.

It comes down to avoid the 2.3333, somehow it is overruled in my script.

python problem with fRange 01.gh (7.3 KB)

python problem with fRange 02.gh (5.9 KB)

`import rhinoscriptsyntax as rs`

``````def fRange(start, end, step):
list = []
list.append(start)
temp = list[0]
while (temp <= end):
temp += (end/step)
list.append(temp)
list.pop(-1)
return list

a = fRange(x, y, z)``````

frange() is a rhinoscript specific function. you can call it by using rs.frange(start, end, step). it is for numbers of the type “float”, hence the f in frange.
is this they type of thing you are after?

``````import rhinoscriptsyntax as rs

def myFrange(x, y, z):
vals = []
for i in rs.frange(x, y, z):
vals.append(i)
if u:
vals.append(y)
else:
pass
return vals

a = myFrange(x, y, z)
``````
1 Like

Chris Hanley is correct，But you can also try your method，I made some minor changes.like this

Code：
import rhinoscriptsyntax as rs

``````def fRange(start, end, step):
list = []
list.append(start)
temp = start
while (temp <= end):
temp += step
if(temp<=end):
list.append(temp)
else:
list.append(end)
return list

a = fRange(x, y, z)``````
1 Like

This is my interpretation of what you are trying to achieve. This gives the start value as x, the end value as y and the total number of steps (including the start and end) equal to z.

import rhinoscriptsyntax as rs

def fRange(start, end, step):
list = []
temp = start
qty = int(step-1)
list.append(start)
for i in range(0,qty):
temp += ((end-start)/(step-1))
list.append(temp)
return list

a = fRange(x, y, z)

1 Like