I am trying to find the size of the turtle screen in replit so that I can know where the turtle has went out of bounds.
Here is my code:
import turtle as t
from random import randint as r
import sys
window = t.Screen()
pet = t.Turtle()
def rand_color():
  red = r(0, 255)
  green = r(0, 255)
  blue = r(0, 255)
  pet.color(red, green, blue)
def random_turtle(num_moves):
  global count
  while count < num_moves:
    rand_color()
    pet.forward(r(10, 100))
    check()
    pet.right(r(0, 360))
    check()
    count += 1 
def check():
  global count
  x = t.xcor()
  y = t.ycor()
  if x > 350 or x < -350:
    t.right(180)
    if count > 100:
      sys.stop()
    else:
      random_turtle(100 - count)
  elif y > 330 or y < -320:
    t.right(180)
    if count > 100:
      sys.stop()
    else:
      random_turtle(100 - count)
  else:
    random_turtle(100 - count)
If there is an easier method than finding the size of the turtle screen and dividing the x by 2, please let me know in the comments!
 
    