0

Python iterating through array of floats

pointArray contains floats in form [[x1 y1 z1][x2 y2 z2]...[xn yn zn]] for point in pointArray xVal, yVal, zVal = tuple(point[0]) Returns TypeError: ‘float’ object is not iterable

11th Mar 2018, 6:50 PM
Acrimonious Mirth
Acrimonious Mirth - avatar
8 Respostas
+ 8
But I think the problem is: xVal, yVal, zVal, = tuple (point[0]) use xVal, yVal, zVal, = tuple(point) or just xVal, yVal, zVal, = point because point[0] is a float and a float cannot be converted to a tuple (a tuple is an iterable)
11th Mar 2018, 6:58 PM
David Akhihiero
David Akhihiero - avatar
+ 4
Please provide the full code
11th Mar 2018, 6:52 PM
David Akhihiero
David Akhihiero - avatar
+ 4
Then provide a code snippet, with actual values not variable names
11th Mar 2018, 6:56 PM
David Akhihiero
David Akhihiero - avatar
+ 4
[[x1,y1,z1],[x2,y2,z2],.....]
11th Mar 2018, 6:56 PM
Oma Falk
Oma Falk - avatar
+ 1
That would be tricky, there is a lot of it and the issue is in this section.
11th Mar 2018, 6:55 PM
Acrimonious Mirth
Acrimonious Mirth - avatar
+ 1
I’ll check that, Yerucham. I was reusing some old code, processing points now.
11th Mar 2018, 7:00 PM
Acrimonious Mirth
Acrimonious Mirth - avatar
+ 1
That worked, thanks! I remember now that the tuple was there to preserve some structure from another library and so isn’t necessary here.
11th Mar 2018, 7:02 PM
Acrimonious Mirth
Acrimonious Mirth - avatar
11th Mar 2018, 7:05 PM
Acrimonious Mirth
Acrimonious Mirth - avatar