Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Python please ! Write a function orderlunches ) that takes two arguments, in this order: 1. stock: A dictionary that contains menu items available
In Python please !
Write a function orderlunches ) that takes two arguments, in this order: 1. stock: A dictionary that contains menu items available for purchase at a restaurant. The dictionary maps items to an integer count of how many of each item is available (e.g., 'soda' : 4). 2. orders: A list of strings representing items that patrons at the restaurant have ordered. The list might include items not available for purchase. The function iterates over the orders list, treating each string in the list as a key in the stock dictionary. If the key is present in the dictionary, the function decrements the value associated with the key (provided that doing so would not make the value negative). The function also returns the total number of valid items purchased. TheStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started