Oct-28-2023, 12:52 PM
Hello,
I'm trying to make a board with turtle ( which I'm new to ) using loops and functions, but nothing seems to work. When I run the script, nothing happens. (I use Pyzo as an IDE)
There are 2 functions : one for making the lines, and one for making the columns. There must be a loop that repeats for n times which determines the number of lines there will be. ; length is obviously the number of pixels the line will be. It's the same thing for columns . Also, between each lines / columns, there must be 20 pixels.
Here is my code :
Thanks !
I'm trying to make a board with turtle ( which I'm new to ) using loops and functions, but nothing seems to work. When I run the script, nothing happens. (I use Pyzo as an IDE)
There are 2 functions : one for making the lines, and one for making the columns. There must be a loop that repeats for n times which determines the number of lines there will be. ; length is obviously the number of pixels the line will be. It's the same thing for columns . Also, between each lines / columns, there must be 20 pixels.
Here is my code :
import turtle def lines(n,length): for i in range(n): turtle.pen(fillcolor = "blue", pencolor = "black", pensize = 3) turtle.forward(length) turtle.up() turtle.right(90) turtle.forward(20) turtle.left(90) turtle.down() turtle.up() turtle.end_fill() turtle.done() window.exitonclick() lines(3,32) def columns(n,length): for i in range(n): turtle.pen(fillcolor = "green", pencolor = "black", pensize = 3) turtle.right(90) turtle.forward(length) turtle.up() turtle.left(90) turtle.forward(20) turtle.right(90) turtle.down() turtle.end_fill() turtle.done() window.exitonclick() columns(5,7)Can someone help a beginner ?
Thanks !