I'd like to make a suggestion if you don't mind—maybe it could help. There are well-developed terminal emulators for Arduino, such as Shellminator. If you don’t want to bother implementing your own UART command and data handler, feel free to use Shellminator:
It creates a proper terminal interface, almost like Linux, and it's very easy to associate commands with it—just a few lines of code. You can also add arguments to commands, making it extremely flexible. There are plenty of examples available, and I think the documentation is really good:
https://www.shellminator.org/html/200_commander_basic_page.html
I’d also recommend considering synchronizing communication. You'll achieve much more stable operation if the master (in this case, the Python script) requests sensor values instead of the microcontroller sending data on its own. In general, it's best if the microcontroller only responds when asked—this way, the communication stays structured and doesn't get out of sync.