'How can I use classes for python turtle to define a position? error message - TypeError: turtle.Vec2D() argument after * must be an iterable, not int
This is the code
import turtle
from turtle import *
class character:
Solution 1:[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)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | gnash117 |