Share your repls and programming experiences

← Back to all posts
A random walking turtle
jeremymclaughlin (3)

Using the Turtle and Random libraries, let your turtle take a random walk.

Comments
hotnewtop
plant3jyyehejy (15)

You should check boundary collisions to pervert bob from going of screen
Heres how i do it

if bob.xcor() > 500 or bob.xcor() < -500 or bob.ycor() > 400 or bob.ycor() < -400:
    Bob.home()

You can replace the numbers depending on how big your boundaries are
bob.xcor() has the value of where bob is horizontally (the center being the origin)
bob.ycor() has the value of bobs position vertically
bob.home() send bob back to the center of the screen