🐸

The Blueprint

Python Basicspython-basics-15-the-blueprint
Reward: 100 XP
|

The Builder unrolls a massive blue scroll. "This is the Blueprint," he explains. "In other lands, builders use braces {} or keywords to mark the beginning and end of a room. But here in Pythonia, we use Indentation."

He points to a messy pile of bricks. "Without proper alignment, everything collapses."

The Law of Alignment

In Python, whitespace at the beginning of a line is not just for looks—it determines the structure of your code. Statements that belong together (like the commands inside an if) must be indented by the same amount of spaces. The standard is 4 spaces.

if True:
print("This will cause an IndentationError!")
if True:
  print("This is safe inside the block.")
  print("This is also inside.")
print("This is outside, back on the main level.")
1
The Error

The code on the right is trying to build a structure, but the indentation is all wrong.

2
Fix Indentation

Fix the IndentationError by adding spaces (Tab key) to push the code blocks inside their respective if statements.

3
Fix Logic

The nested if (checking materials_ready) should be inside the first if. And the print statements about building should be inside the second if.

If you mix tabs and spaces, the Python interpreter will get confused and might throw an error. Stick to spaces (or let the editor convert Tab to spaces)!

Advanced Tips
Want more? Click to expand

Python's use of indentation to mark blocks is often called the "off-side rule". Most other programming languages (like C, Java, JavaScript) use curly braces { } to define blocks, and indentation is just for readability. In Python, readability is the syntax.

pymain.py
Loading...
Terminal
Terminal
Ready to run...