how to change screen coordinates to world coordinates

so im writing a simple game in python, and basically have diffrent targets on the screen that i need to hit with the mouse, but since mouse x and mouse y is relative to the screen but the target is relative to the world the coordinates never match, how can i change the coordinates of the mouse so i will be able to find when i hit the targets and when miss

What you described is commonly referred to as “picking”.
For picking on a simple plane:
For picking more complex stuff: … 3D_Objects
For picking even more complex stuff, consider doing this on the GPU, with an occlusion query or 1x1 buffer.

while i understand how it works i’m not sure how i should change the program for my purpose, so i will look for intersection of the mouse with a simple 2d model