Python Forum
Trying to make a board with turtle, nothing happens when running script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to make a board with turtle, nothing happens when running script
#4
This loop draws 1 line.
    for i in range(n):
        turtle.pen(fillcolor = "blue", pencolor = "black", pensize = 3)  # Place in front of loop.
        turtle.forward(length)
        turtle.up()
        turtle.right(90)
        turtle.forward(20)
        turtle.left(90)
        turtle.down()
        turtle.up()  # <- Pen is up when second iteration of loop runs
I would start by changing the code to this:
import turtle


def lines(n, length):
    turtle.pen(fillcolor="blue", pencolor="black", pensize=3)
    turtle.begin_fill()
    for i in range(n):
        turtle.forward(length)
        turtle.up()
        turtle.right(90)
        turtle.forward(20)
        turtle.left(90)
        turtle.down()
    turtle.end_fill()


def columns(n, length):
    turtle.pen(fillcolor="green", pencolor="black", pensize=3)
    turtle.begin_fill()
    for i in range(n):
        turtle.right(90)
        turtle.forward(length)
        turtle.up()
        turtle.left(90)
        turtle.forward(20)
        turtle.right(90)
        turtle.down()
    turtle.end_fill()


lines(3, 32)
columns(5, 7)
turtle.done()
Now you can at least see the turtle errors.
Reply


Messages In This Thread
RE: Trying to make a board with turtle, nothing happens when running script - by deanhystad - Nov-01-2023, 03:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  No Internet connection when running a Python script basil_555 8 715 Mar-11-2024, 11:02 AM
Last Post: snippsat
Question Running Python script through Task Scheduler? Winfried 8 591 Mar-10-2024, 07:24 PM
Last Post: Winfried
  Make entire script run again every 45 mo NDillard 0 344 Jan-23-2024, 09:40 PM
Last Post: NDillard
  Help Running Python Script in Mac OS emojistickers 0 373 Nov-20-2023, 01:58 PM
Last Post: emojistickers
  Python script running under windows over nssm.exe JaroslavZ 0 744 May-12-2023, 09:22 AM
Last Post: JaroslavZ
  Running script with subprocess in another directory paul18fr 1 3,944 Jan-20-2023, 02:33 PM
Last Post: paul18fr
  Make console show after script was built with Pyinstaller --NOCONSOLE? H84Gabor 0 1,235 May-05-2022, 12:32 PM
Last Post: H84Gabor
Photo HOW FIX MY BOARD GAME LAZABI 3 1,505 Apr-01-2022, 04:23 PM
Last Post: BashBedlam
  Make my py script work only on 1 compter tomtom 14 3,955 Feb-20-2022, 06:19 PM
Last Post: DPaul
  The game should now run and terminate once the board is full, but still can’t identif rango 0 1,474 Jul-22-2021, 03:24 AM
Last Post: rango

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020