Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- receipt = []
- products = {
- "Fries": 2,
- "Bacon": 3,
- "Hashbrowns": 3,
- "Water": 1,
- "Sprire": 2,
- "Cola": 2,
- "Burger": 4,
- "Hotdog": 3,
- "Salad": 4,
- }
- for key, value in products.items():
- print("Item: {:<12}\tPrice: ${:>5.2f}".format(key, value))
- accumulator += value
- print("")
- print("Grand total for all is " + value)
- idx = 0
- # using a while loop
- while idx < len(products):
- print(" Meal #" + str(idx) + " " + str(products[idx]))
- # incrememt idx by 1
- idx += 1
- print(idx)
- print("What would you like to order? (Type 'Done' once finished)")
- total = 0 #Variable for the total
- while (True): #Loop for user input for items
- order = input("Enter Item: ")
- if (order.lower() == "done"): #breaks the loop by typing done, even if uppercase
- break
- elif (
- order not in str((idx))): #Makes sure items are in the menu if not brings them back with invalid order
- print("Invalid Order")
- continue
- else:
- amount = (int)(input("How many: ")) #Allows the user to select how much of an item they desire
- total += products[order] * amount #Adds price to total, also uses the amount var
- receipt.append((str)(amount) + " orders of meal of order #" + (order) + " Current Total is " + str(total) + "$")
- print("")
- print("$" + (str)(total))
- #Parts of loop above taken from Reddit post, sections mostly changed around other than basics
- print("Total: ${}".format(total)) #Prints the total for user
- print(receipt)
- print()
- print("Complete")
- print("")
- print('Added the subscripts to the print line in our for loop.')
- if __name__ == "main":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement