![]() Assuming nothing goes wrong, the else section will execute once the try section is completed. If you’re still unsure about how the code block works, the try section will execute and if anything goes wrong the except section will take place. ![]() exiting:",e) exit() else: # convert the file and save the output Here’s the outlined structure: try: # ask for the filename # load data except Exception as e: # print error message, exit script print("Error opening file. So we’re going to use a try/except/else statement to control the flow of our script. We could do a simple input, however, if the file doesn’t exist, the rest of our script won’t work. From here, the next step is to ask for the file to load.
0 Comments
Leave a Reply. |