Apr-12-2024, 07:57 AM
Note : its my first program in python (i used to script for roblox games in lua)
~Thank you~
menu = {} menu["sandwich"] = 20; menu["burger"] = 25; menu["pizza"] = 30; menu["steak"] = 30; menu["pork"] = 25; menu["chicken"] = 10; orders = {}; numOfOrders = 0; def negate_S(word): word = list(word); totalLetters = len(word); if word[totalLetters - 1] == "s": word.pop(totalLetters - 1); totalLetters -= 1 if word[totalLetters - 1] == "e": word.pop(totalLetters - 1); newStr = ""; for letter in word: newStr += letter; return(newStr); def keywordSearch(customerInput): splitArray = customerInput.split(); for word in splitArray: word = negate_S(word.lower()); if word in menu: return word; return; def getQuantity(customerInput): splitArray = customerInput.split(); for word in splitArray: if word.isdigit(): return word def checkYesOrNo(string): string = string.lower(); splitArray = string.split(); for word in splitArray: if word == "yes" or word == "yeah": return True; else: return False; while True: customerInput = str(input("Please Enter your order: ")); CustomerOrder = keywordSearch(customerInput); quantity = getQuantity(customerInput); checkOrder = str(input("You want to order " + str(quantity) + " " + CustomerOrder + ("s") + "?" + ": ")); checkOrder = checkYesOrNo(checkOrder); if checkOrder: orders[CustomerOrder] = quantity; checkOrderAgain = str(input("Do you want anything else: ")); checkOrderAgain = checkYesOrNo(checkOrderAgain) if checkOrderAgain: print("==================="); print(""); continue; else: print(""); print("==================="); print(""); print("Your Order: "); for orderName, orderQuantity in orders.items(): print(orderName + "s x" + str(orderQuantity)); print(""); print("==================="); print("Ty for ordering") print("==================="); break; else: print("Sorry for the error"); print("==================="); print(""); continue;
~Thank you~