In MicroPython there is no Debug option like in regular Python and other coding languages. If you want to track and debug the code you can do it by making use of the system interrupts. you can implement a try & catch in the code and by catching a specific interrupt you can then run a specific code for detailing the interrupt to keep track and debug you code.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This code safely handles an IndexError when trying to access an out-of-range index in a list. The try-except block ensures the program continues running without crashing.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Resources and websites: