# Functions go here import pandas def string_check(question, valid_list=('yes', 'no'), num_letters=1): """Checks that users enter the full word or the first 'n' letters from a list""" while True: response = input(question).strip().lower() for item in valid_list: item_low = item.lower() if response == item_low: return item elif response == item_low[:num_letters]: return item print(f"Please choose an option from {valid_list}") def instructions(): print("Pizza Paladin Instructions," "ℹ️") print(""" The program will record the users data that they entered, then proceed to the main menu of what Pizza Paladin offers. Once you have ordered your pizza (up to 5 maximum allowed), or entered the exit code (‘xxx’), the program will display the receipt information regarding the customers order, writing the data to a text file. The program proceeds by asking would you like to pick-up or deliver the pizza to your address. For each customer should enter ... ------ (IF PICK-UP WAS CHOSEN) ------ - Their name - Phone number - The payment method (cash / credit) ------ (IF DELIVERY WAS CHOSEN) ------ - Their name - Phone number - Address - The payment method (cash / credit) The program will record the users data that they entered, then proceed to the order by printing a receipt """) def make_statement(statement, decoration, lines=1): middle = f"{decoration * 3} {statement} {decoration * 3}" top_bottom = decoration * len(middle) if lines == 1: print(middle) elif lines == 2: print(middle) print(top_bottom) else: print(top_bottom) print(middle) print(top_bottom) def not_blank(question): """Checks that a user response is not blank""" while True: response = input(question) if response != "": return response print("Sorry, this can't be blank. Please try again.\n") def int_check(question): """Checks users enter an integer that is more than zero (or the 'xxx' exit code)""" error = "Oops - please enter an integer." while True: response = input(question).lower() if response == "xxx": return response try: response = int(response) if response > 0: return response else: print(error) except ValueError: print(error) def currency(x): """Formats numbers as currency ($#.##)""" return "${:.2f}".format(x) # write to file file_name = "Pizza_data_experiment" write_to = "{}.txt".format(file_name) text_file = open(write_to, "w+") # strings to write to file... heading = "=== Pizza Test ===\n" user_details = "" pickup_or_delivery = "" # list of strings to_write = [heading, user_details, pickup_or_delivery] # print the output for item in to_write: print(item) # write the item to file for item in to_write: text_file.write(item) text_file.write("\n")