on-internet
← Community

Can't prevent python turtle from going outside the window

Stack Overflow ·

As you can see from my code, I've written a simple program with the turtle module to randomly draw lines with a random color. The turtle will randomly move forward or backward with a random distance which is chosen from a list. What I would like to do is to prevent the turtle to go outside the window border. I've tried different things, searched on this website, also asked to chatGpt but none solution found solved the problem. Can someone fix my code explaining to me what I'm doing wrong? import random import turtle from turtle import Turtle, Screen my_screen = Screen() my_screen.setup(800, 60

Comments

Sign in or sign up to comment and upvote.

No comments yet.