CJCoding With Joseph
15free / daySign inCreate account

Remove From Stock

Write the whole Inventory class. The constructor creates an empty dict attribute stock from item name to quantity; add(item, quantity) tops up an existing key or creates it; remove(item, quantity) subtracts from the stored quantity, but when the item is missing or holds fewer than requested it prints Not enough <item> and changes nothing. Do NOT write a main block or any top-level test code; the tests construct the class. Input: two lines, an item name and a whole-number quantity, which the tests pass to remove on an inventory holding 5 apples; the tests then print each item and its quantity on one line, in alphabetical order.

Expected Output:

apple 3

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
Classes
📥 Auto-Input:
apple\n2\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.