fixme1.py

Published: April 2, 2026

Description

Fix the Python syntax error to print the flag. The script has an indentation error.

Download fixme1.py from the challenge page.

Open it in a text editor.

Solution

  1. Step 1Identify the indentation error
    Run the script to see the error message. Python will report an IndentationError pointing to the line with extra leading spaces. Locate the print() call that has incorrect indentation.
    python3 fixme1.py
    Learn more

    Python uses indentation -- the whitespace at the start of a line -- to define code structure. Unlike languages that use curly braces {} to group statements into blocks, Python treats the indentation level itself as meaningful syntax. A line indented too far for its context triggers an IndentationError.

    When Python reports an IndentationError, it tells you the exact line number where the problem was detected. However, the cause is often a few lines earlier -- for example, a missing colon at the end of an if statement can confuse the parser into expecting a different block structure.

    Running the script before reading it is a valuable debugging strategy: let the interpreter tell you what is wrong rather than hunting through the file manually. The error message, line number, and caret (^) marker together pinpoint the issue precisely.

  2. Step 2Fix the indentation
    Remove the extra leading spaces from the flagged line so it aligns with the correct indentation level for its code block. In Python, indentation defines block structure -- unexpected indentation is a syntax error.
    Learn more

    Python's style guide (PEP 8) recommends using 4 spaces per indentation level -- never mixing tabs and spaces. Most modern editors can be configured to insert 4 spaces when you press Tab, avoiding the tab/space mixing issue entirely.

    Indentation errors fall into two categories:

    • IndentationError: unexpected indent -- a line is indented more than expected (the case in this challenge).
    • IndentationError: expected an indented block -- a block-starting statement (like if, for, def) is not followed by any indented code.

    Fixing indentation is a core skill for any Python developer. In larger projects, tools like flake8 or black automatically detect and fix indentation issues before they reach production.

  3. Step 3Run the fixed script
    Once the indentation is corrected, run the script again and it will print the flag.
    python3 fixme1.py
    Learn more

    Running the script a second time after a fix confirms that the change was correct and complete. This edit-run-verify cycle is the fundamental loop of software debugging -- make a hypothesis, apply a change, confirm the result.

    If new errors appear after fixing the first one, that is normal: Python stops parsing at the first syntax error it encounters, so fixing one issue can reveal others that were hidden. Work through errors one at a time from top to bottom.

Flag

picoCTF{...}

Python uses indentation to define code blocks -- extra spaces where none are expected cause an IndentationError, while inconsistent mixed tabs and spaces cause a TabError.

More General Skills