Three items are available and five are required. Printing a Boolean tells us whether the quantity is sufficient. This time, give the program a choice: flag a negative quantity, request more stock or confirm there is enough.
Turn a comparison into an action
An if statement tests a condition. Python checks the conditions in order and executes the block belonging to the first true condition, skipping the rest of that chain.[2] elif means “else if”; you can add several elif branches or leave them out. The optional else provides a fallback when every condition is false.[1][2]
Save this as stock-message.py and run it from the same folder with your working Python launcher:
stock = 3required = 5if stock < 0: print("Invalid stock")elif stock < required: print("Restock")else: print("Enough stock")print("Check complete")
python3 stock-message.py
RestockCheck complete
Here, 3 < 0 is false, so Python reaches 3 < 5. That condition is true: Restock is printed and the else block is skipped. The final, unindented line prints Check complete after the choice. This example was tested with Python 3.14.9 on Linux, using no extra packages.

Make the block visible
Each header ends with a colon. Align if, elif and else, then indent the statements belonging to each branch.[2] Use four spaces for each indented line here. Keep that spacing consistent when editing. Removing the indentation from a branch's print() caused an IndentationError in our test; the script stopped before printing a message.
A common mistake: starting another check
Changing elif to a second if starts a separate decision. With a negative quantity, both checks below succeed:
stock = -1if stock < 0: print("Invalid stock")if stock < 5: print("Restock")
python3 separate-checks.py
Invalid stockRestock
The first example keeps those outcomes exclusive. Its negative-stock branch catches -1 before the restocking test is reached. Use that chain when the program should select one message.
Your turn
In stock-message.py, change only stock to -1, 0, 5 and 6, running the file after each edit. Predict the message and check that Check complete follows every time. Which branch handles exactly five items? Next: repeat an action with a while loop.