Basic Network connection, Python between two Raspberry for GPIO Ping-Pong

While countless code examples on the internet are great. I feel like my basic understanding of device-to-device network connectivity is lost in the ocean of internet examples with web interfaces, GUI’s and talking mirrors.
My goal is a device-to-device communication program and basic GPIO logic for an Output (light) & Input (button) for the program interface (No GUI). This program would start by illuminating the light on one Raspberry and wait for that person to press the button. When pressed, a message would be sent to the 2nd Raspberry and that light would illuminate. When the other user presses their button, a message would be sent returning the light back to the first Raspberry. This would loop until someone stopped responding.
This post is to ask for reference to basic LAN network communication example programs. I feel like I need to learn/understand this part better and hope someone can recommend an example to work with.
Any recommendations for a simple Client/Application pair or similar to use for reference?

The keyword you’re looking for is sockets. The low-level networking package in the standard library is called socket, which is a fairly thin layer around the classic C API. The API docs may be a bit hard to digest for someone not familiar with TCP/IP programming.

I can’t recommend any tutorials as such, but googling ‘python socket example’ or something like that should help you find what you’re looking for.