I am trying to define a function that will take in a list of lengths from a shape like this:
And return the coordinates of each point.
Here is what have so far:
def cord(lst):
lst2 = [[0,0]]
d = 'up'
c = [0,0]
for n in lst:
if d == 'up': # if the direction is up, we add the value to the y cor
c[1] += n
lst2.append(c)
d = 'right' # After up, we go right
else: # if the direction is right, we add the value to the x cor
c[0] += n
lst2.append(c)
d = 'up' # After right, we go up
print(lst2)
cord([10,10,10])
Output:
[[0, 0], [10, 20], [10, 20], [10, 20]]
Desired output:
[[0, 0], [0, 10], [10, 10], [10, 20]]
Can you tell me what's wrong?