fixme1.py Beginner picoMini 2022 Solution

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.

Solution

Want to try it yourself first?

The guided walkthrough reveals hints one step at a time.

Walk me through it
  1. Step 1
    Identify the indentation error
    Observation
    I noticed the challenge description explicitly stated an indentation error exists in fixme1.py, which suggested running the script immediately to let Python's parser report the exact line and error type rather than scanning the file manually.
    Run the script. Python reports an IndentationError: unexpected indent, pointing to the exact line with extra leading spaces.
    python
    python3 fixme1.py

    Expected output

      File "fixme1.py", line 8
        print('That is correct! Here is your flag: ' + flag)
        ^
    IndentationError: unexpected indent
    What didn't work first

    Tried: Open the file in a text editor first and scan it visually for extra spaces before running it.

    Stray spaces are nearly invisible to the eye, especially when mixing tabs and spaces that both render as whitespace. Running the script first lets Python's parser pinpoint the exact line number with a caret marker, which is far more reliable than visual inspection.

    Tried: Run the script with python2 fixme1.py instead of python3.

    Python 2 and Python 3 enforce indentation rules identically, so switching interpreters does not change the IndentationError. Python 2 also reaches end-of-life and is absent from most modern systems, so the command may not be found at all.

    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 2
    Fix the indentation
    Observation
    I noticed Python's error output named the exact line with unexpected leading spaces, which suggested opening fixme1.py in an editor and removing those extra spaces so the flagged line aligns with the surrounding statements.
    Open fixme1.py in a text editor (nano works well here). Remove the extra leading spaces from the flagged line so it aligns with the surrounding statements. In Python, a line indented deeper than its context triggers an IndentationError.
    bash
    nano fixme1.py
    What didn't work first

    Tried: Press Tab in nano to fix the indentation instead of using spaces.

    By default, nano inserts a literal tab character when you press Tab. If the rest of the file uses spaces, mixing in a tab triggers a TabError or leaves the indentation visually correct but syntactically wrong. Use the space bar to insert spaces that match the surrounding lines.

    Tried: Delete the entire print line and retype it at the correct indentation level.

    Retyping introduces risk of new typos in the string or variable names. The safer fix is to move the cursor to the start of the line and delete only the extra leading spaces, leaving the rest of the line unchanged.

    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 3
    Run the fixed script
    Observation
    I noticed the only reported error was the single IndentationError on the print line, which suggested that correcting that one line should allow the script to execute cleanly and print the flag.
    Once the indentation is corrected, run the script again and it will print the flag.
    python
    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

Reveal flag

picoCTF{1nd3nt1ty_cr1515_...}

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.

Key takeaway

Python uses whitespace indentation as syntax rather than decorative style, which means a stray space or tab can prevent a script from running entirely. Reading error messages carefully is the correct debugging strategy: the interpreter reports the exact line number and error type, letting you fix issues without guessing. This edit-run-verify cycle is universal across every programming language and every security tool you will build.

Related reading

Want more Beginner picoMini 2022 writeups?

Useful tools for General Skills

What to try next