I have a headless PiZero and off button that works with code that loops and polls. I would like to use the interrupt method. The intent is to have the button press first close a CSV file then shutdown the Pi.
As a beginner/novice I don't understand where the try: loop shown in the online examples resides relative the other code and functions. Is it in the function and def section, separate file, or somewhere else?