0

This is the code

import turtle
from turtle import *

class character:
  • Please [edit] your question to include a [mcve] and the entire error message. – Code-Apprentice Apr 08 '22 at 15:31
  • Please provide a sentence or two about what you are trying to do. Then, describe what you tried to debug the error, and then formulate a question. – Donna Apr 09 '22 at 07:19
  • Original poster edited the question to be complete nonsense. To the point my Answer looks like random code pulled out of no-where when it was directly referencing OPs code posted in the original question. :( – gnash117 Apr 28 '22 at 18:55

1 Answers1

1

The position is two values not one. You need to use a tuple or two parameters.

example:

import turtle
from turtle import *

class character:

 def __init__(self,name, x, y=None ):
   self.__name = name
   self.__xposition = x
   self.__yposition = y
   self.__t = Turtle()

 def help(self):
   print(self.__name)
   self.__t("turtle")
   self.__t.goto(self.__xposition, self.__yposition)

 player = character("hello", -150, 40)
gnash117
  • 1,025
  • 1
  • 13
  • 24
  • How would I then call the turtle to go forward in another class? Do i call it by saying self.__name = forward(3) –  Apr 08 '22 at 22:53
  • You have 3 ways: 1. add a forward method to your character class that calls self.__t.forward 2. make the Turtle outside the class and pass it in to individual classes 3. make an accessor function to access the Turtle. if the Turtle is the character then why not make a list of Turtles? – gnash117 Apr 28 '22 at 18:39