Basics

Module 2 · Basics · Lesson 4 of 9

Instructions

A call like print("Hi") is one instruction — a single order for Python to carry out. Real programs are made of many of them, so how do you put more than one together? Python has a firm opinion here.

One line, one instruction
✗ Two on one line
print("Hi") print("Bye")
SyntaxError: invalid syntax
✓ One per line
print("Hi")
print("Bye")
Hi
Bye

Unlike a lot of languages, Python expects one instruction per line. A line is free to be empty, but it must never carry two or three instructions crammed together — try it and Python stops with a SyntaxError. Give each instruction its own line and they run in order, top to bottom.

There's one exception worth knowing: a single instruction is allowed to spread across several lines. That's handy later, when a line would otherwise grow long and hard to read — but it's still one instruction, just stretched out. The rule holds: one instruction per line, never several jammed onto one.