Pseudocode to Python: Order Validator
Translate the following pseudocode into working Python, preserving its logic exactly:
INPUT stock
INPUT orders (a list of quantities)
FOR each order (quantity) in orders:
IF quantity <= stock THEN
OUTPUT "Fulfilled: " + quantity
stock = stock - quantity
ELSE
OUTPUT "Rejected: " + quantity
ENDIF
ENDFOR
OUTPUT "Remaining stock: " + stock
Read the starting stock, then the number of orders, then that many order quantities. Process each order against the pseudocode's logic exactly, then print the final remaining stock.
main.py
Loading editor…
Console
Run your code to see output here.