use python to create 2D coordinate
I am truly novice in python. Now, I am doing a project which involves
creating a list of 2D coordinates. The coordinates should be uniformly
placed, using a square grid (10*10),
like(0,0)(0,1)(0,2)(0,3)...(0,10)(1,0)(1,2)(1,3)...(2,0)(2,1)(2,2)...(10,10)
Here is my code:
coordinate = []
x = 0
y = 0
while y < 10:
while x < 10:
coordinate.append((x,y))
x += 1
coordinate.append((x,y))
y += 1
print(coordinate)
But I can only get:[(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6,
0), (7, 0), (8, 0), (9, 0), (10, 0), (10, 1), (10, 2), (10, 3), (10, 4),
(10, 5), (10, 6), (10, 7), (10, 8), (10, 9)] How can I rewrite my code to
get all the points? Thanks
No comments:
Post a Comment