(Jun-10-2020, 09:30 AM)DPaul Wrote: Are you sure the coordinates draw a heart ? :-)yes it needs to draw an ugly heart ; maybe i didn't give it entirely ;
It works , but i get the start of a heart +/- ...
What i did:
D is now a list of dictionaries.
"For coord in D:" is what Yoriz says.
Each coord has 2 dictionary keys ['X'] and ['Y'], that give simple access to the values.
After that, piece of cake.
Also, do not include D in your def call, as D is visible from within the def.
Paul
D1 = [{'X': -15, 'Y': 29}, {'X': -22, 'Y': 13}, {'X': -18, 'Y': -2}, {'X': -19, 'Y': -7}, {'X': -17, 'Y': -17}, {'X': -7, 'Y': -15}, {'X': -4, 'Y': -29}, {'X': 6, 'Y': -21}, {'X': 20, 'Y': -17}, {'X': 37, 'Y': -27}, {'X': 45, 'Y': -26}, {'X': 60, 'Y': 48}, {'X': 18, 'Y': 29}, {'X': 11, 'Y': 30}, {'X': -2, 'Y': 30}, {'X': -22, 'Y': 24}, {'X': -22, 'Y': 4}, {'X': -22, 'Y': 2}, {'X': -20, 'Y': -10}, {'X': -8, 'Y': -33}]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
it still doesn't work def draw_figure(x0,y0): tracer( True ) penup() goto(x0,y0) pendown() begin_fill() for coord in D: pen.right( 'X' ) #to access the index of X pen.left( 'Y' ) end_fill() print (draw_figure( 10 , 20 ,D1)) |