python - Construct Tuple of Lists with for loop -
i have question python. have function takes input set of 3d points. typically, if this, works fine:
mypoints=([0,0,0],[1,1,1],[2,2,2]) myfunction(mypoints)
the problem generate tuple "mypoints" "dynamically" (i.e. loop). example:
mypoints=([0,0,0]) k in range(1,11) mypoints=mypoints+tuple([k,k,k]) myfunction(mypoints)
the problem code above sends me error when call function. tells me have "too many arguments".
so question simple: how can construct tuple of form: mypoints=([0,0,0],[1,1,1],[2,2,2],[3,3,3]) (etc.)
using loop?
thank in advance , time.
edit: response, actuallz nothing works fault. sorry. onlz szntax accepted following:
myfunction(((0,0,0),),((1,1,1),),((2,2,2),),((3,3,3),)))
does know how build such structure using loop? again , sorry confusion!
best, julia
you converting list tuple when intend create singleton tuple containing list:
what you're doing:
>>> tuple([1,1,1]) (1, 1, 1)
what want:
>>> ([1,1,1],) ([1, 1, 1],)
mypoints=([0,0,0],) # notice , ... mypoints = mypoints + ([k,k,k],)
Comments
Post a Comment