# Chapter8Main.py # imports from Chapter8Modules import filename,write_to_csv,read_from_csv # globals -> variables that will be used in the scope of this file # main() function def main(): # pass # Chapter 8 try/except with optional finally keyword try: # try running this line of code -> pass or fail print("Welcome to our order system.") # use a while keyword to enter order information while True: # in this loop we will ask the user if they want to continueyes or break!yes ## orderID: int ## orderTotal: float ## orderProcessed:str -> Yes/No ## ccApproved: str Approved/Declined orderID = int(input("Enter Order ID as int: ")) orderTotal = float(input("Enter Order Amount: ")) orderProcessed = input("Has the order been processed for shipping: (Yes/No) ").title().strip() ccApproved = input("Approved or Declined: ").title().strip() write_to_csv(orderID, orderTotal, orderProcessed, ccApproved) # Ask the user if they want to add another or are they done runAgain = input("Do you want to add another order? (Yes/No) ").title().strip() if runAgain != "Yes": # YES, yes, YeS,... break # read all the current orders from the orders.csv file read_from_csv() except Exception as error: print(f"{error}") finally: # run always -> Exit Code 0 Pass and Exit Code 1 Fail # optional keyword but highly recommended print("Thank you.") # close streams, garbage collection, any final tasks that need to be done no matter what happens # main statement if __name__ == "__main__": main()