I’m doing a “Payment machine” project, it’s supposed to have a menu with 2 options. 1st option is “Take Payment” Where you’re asked to enter card number, Payment amount, if payment amount is greater than maximum amount from external file you are prompted to enter PIN number. The inputs should be saved at an external file. Any suggestions?
def mainMenu(): print(30 * "-", "MENU", 30 * "-") print("1. Take Payment") print("2. System config") def payment(): paymentAmount = str(input('Please enter payment amount: £')) cardNumber = input('Enter your 16 digit card number: ') if paymentAmount > file_contents: pinNumber = int(input('Enter your 4 digit PIN number: ')) file = 'paymentamount.txt' with open(file, 'a') as f: f.write(paymentAmount + "\n") f.write(cardNumber + "\n") # # You can add your code or functions here print("Payment Succeseful") mainMenu() def config(): print(f.read) filepath = 'golf.txt' with open(filepath, 'r') as f: # Get the entire contents of the file file_contents = f.read() # Remove any whitespace at the end, e.g.a newline file_contents = file_contents.strip() # # You can add your code or functions here mainMenu() choice = input("Enter your choice [1-2]: ") while True: mainMenu() choice = input("Enter your choice [1-2]: ") if choice == 1: payment() break elif choice == 2: config() break else : print("Invalid choice. Enter 1-3") mainMenu()