Error in IEnumeratorOfTWrapper

When I going to make a srf by addSrfPtGrid, it always be Error

import rhinoscriptsyntax as rs
import math

def s(u, v):
x = (1 + ((v - 1) / 2) * math.cos(u / 2)) * math.cos(u)
y = (1 + ((v - 1) / 2) * math.cos(u / 2)) * math.sin(u)
z = ((v - 1) / 2) * math.sin(u / 2)
return rs.CreatePoint(x, y, z)

n = rs.GetInteger(“Value1”)
m = rs.GetInteger(“Value2”)

pts = [ for i in range(n * m - 1)]
for i in range(0, n - 1):
u = 2 * math.pi * i / (n - 1)
for j in range(0, m - 1):
v = 2 * j / (m - 1)
pts[i * m + j] = s(u, v)

rs.AddSrfPtGrid([n, m], pts)Preformatted text

Message: Error in IEnumeratorOfTWrapper.Current. Could not cast: Rhino.Geometry.Point3d in IronPython.Runtime.List

Hey guys, I figured it out. The reason why it always be error is two ranges are wrong, they should not -1 at all.

Correct, range(start, stop, [step]) already is with the stop exclusive.

FYI, here on discourse you can put your code snippets between tripple backticks ``` some code ```. that will give you syntax coloring and preserve your indentation.

Write ```python on the first line, then your code on the subsequent lines. Finally again the ```and you’ll get syntax highlighting for Python. Use different language names for different colorings.

def func():
   pass

THX, It’s the first time I do it. Just know how to do it.