Answered in first comments, thanks all.
I have some of xy coordinate variables and I'm trying to populate a list with the names of those variables but having trouble.
Basically I need to create a loop that creates some X number of variableX and stick them inside a list and am struggling with that.
these are the coordinates lets say:
point1 = [-100, -100]
point2 = [1100, -100]
point3 = [-100, 1100]
point4 = [1100, 1100]
and this is what I'm trying to get without using a loop:
points = [
point1,
point2,
point3,
point4]
But since I'll have some number of points I'm at least trying to automate the second part (since the first one has unique coordinate which is harder to automate).
So my loop rn is:
#variables for the loop
num_points = 20
point_var = "point"
#loop to create list of points
for x in range(1, num_points + 1):
point_var += ("%s" % x)
points.append(point_var)
point_var = "point"
And later I'm using this list in a function to populate points on a map, which works fine without the loop but doesn't work with the loop cause of a type error I'm getting
Traceback (most recent call last):
File "D:\Projects\Voronoi-Map\Voronoi.py", line 101, in <module>
vor = Voronoi(points)
File "qhull.pyx", line 2597, in scipy.spatial.qhull.Voronoi.__init__
File "D:\Software\Python\lib\site-packages\numpy\core\_asarray.py", line 177, in ascontiguousarray
return array(a, dtype, copy=False, order='C', ndmin=1)
ValueError: could not convert string to float: 'point1'
So I'm kinda stuck here, the function expects floats but I converted the names of variables into strings in order to append them inside the loop. Is my approach just flat out wrong? I did something similar in java previously but don't know how to make it work here.
Any advice?