(Mar-15-2019, 08:39 PM)ichabod801 Wrote: Again, you are not being clear. We need the full text of the error you are getting.
Here is the full error text message.
Traceback (most recent call last):
File "C:/Users/hali/Downloads/11.py", line 126, in <module>
L.append(MoveAcorHeight(Lx[i], Ly[i], xgap, ygap, H[i]))
File "C:/Users/hali/Downloads/11.py", line 31, in MoveAcorHeight
return MoveAcorHeight(lx, ly, xgap, ygap, H, itn, K, itn2)
File "C:/Users/hali/Downloads/11.py", line 103, in MoveAcorHeight
return MoveAcorHeight(lx, ly, xgap, ygap, H, itn, K, itn2)
File "C:/Users/hali/Downloads/11.py", line 40, in MoveAcorHeight
PrebsX[K[i][0]].append(lx[i])
IndexError: list index out of range
(Mar-15-2019, 10:56 PM)micseydel Wrote: I'm taking a guess at your issue... Default function parameters are only evaluated once, at function definition. Take this example:
>>> def f(x=[]):
... x.append(True)
... return x
...
>>> f()
[True]
>>> f()
[True, True]
>>> f()
[True, True, True]
Here's the idiom for getting around that issue
>>> def g(x=None):
... if x is None:
... x = []
... x.append(True)
... return x
...
>>> g()
[True]
>>> g()
[True]
>>> g()
[True]
Also, an aside, if you can reproduce your problem in 5-10 lines of code (possible here) that tends to be preferable to longer code and makes it more likely that you get an answer which is both as fast as possible and satisfactory.
Thanks! Problem solved. It was a genius guess!
BTW,I did try to reproduce my code in a shorter version when I started this thread, but that version failed to reflect the facts. Then I failed to reproduce another version.