0

when trying to return the position, python says it is missing mx and my, but when I add them, it says they are not defined

import turtle
def get_mouse_click_coor(mx, my):
    print(mx, my)
turtle.onscreenclick(get_mouse_click_coor)
turtle.mainloop()

1 Answers1

0

What is your filename saved as? Is it turtle.py? if so change the filename and then run the code because your code works on my side.

If that doesn't work try pip install turtle.

I'm sure it's the filename though. Just to note, once you change the filename, it'll change the import name so make sure you change the import back to turtle.

3eeaaa
  • 49
  • 3
  • 1
    Hello, Why do you think the filename is saved as "turtle.py"? Could you elaborate? It may throw an attribution error in that scenario. Also, if the turtle module is not installed it will say "No module named" error. – William Jan 26 '22 at 22:15
  • From what I know, when you are trying to import a package that is named the same as a filename in your project, Python will check your project first before checking packages (at least this is what I believe). If he's trying to import turtle from turtle.py, it won't work because that isn't the package and the functionality OP wants, isn't there. Also agree on the installed or not but OP never provided an error, so I made the assumption OP installed it. – 3eeaaa Feb 03 '22 at 08:59