For some reason, I cannot use a variable to define a space within this certain subset of the function
from turtle import *
john = Turtle()
def naughts(nposition):
john.penup()
john.goto(nposition)
john.right(90)
john.forward(120)
john.left(90)
john.pendown()
john.circle(120)
def crosses(cposition):
john.penup()
john.goto(cposition)
john.pendown()
john.left(45)
for x in range(4):
john.forward(150)
john.backward(150)
john.left(90)
john.right(45)
def main():
pos1= (-400, 400)
pos2= (0, 400)
pos3= (400, 400)
pos4= (-400, 0)
pos5= (0, 0)
pos6= (400, 0)
pos7= -400, -400
pos8= 0, -400
pos9= 400, -400
john.penup()
john.goto(-200, -600)
john.pendown()
john.left(90)
john.forward(1200)
john.penup()
john.goto(200, -600)
john.pendown()
john.forward(1200)
john.left(90)
john.penup()
john.goto(600, -200)
john.pendown()
john.forward(1200)
john.penup()
john.goto(600,200)
john.pendown()
john.forward(1200)
for turns in range(5):
dake = input("Naughts, please choose pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9: ")
naughts(dake)
ecks = input("Crosses, please choose pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9: ")
crosses(ecks)
if __name__ == "__main__":
main()
With the variables at the very end, it returns
"TypeError: Vec2D.new() takes 3 positional arguments but 5 were given", and I'm unsure why.
I have tried to input the positional variables by themselves, which has worked.
This fixes the problem you were having. What I did was make a dictionary containing the coordinates of the moves, and assigned the pos1, pos2... as keys so when the user enters the keys,
POSITIONS[dake]returns the coordinates of thedakeinput.The error was caused because
input()returns a string, and parsing a string into the.goto()attribute caused a Typerror.Now onto win detection...