Skip to main content

fixme1.py Beginner picoMini 2022 Solution

Find and fix a syntax error in a Python script so it runs correctly and prints the flag.

Published: April 2, 2026Updated: August 13, 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 1Identify the indentation error
    Observation
    The description says fixme1.py has an indentation error. Rather than scanning the file by eye, run the script and let Python's parser name the exact line and error type.
    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, especially when tabs and spaces both render as whitespace. Running the script first lets Python's parser point at the exact line with a caret marker, which is far more reliable than hunting for it by eye.

    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 2Fix the indentation
    Observation
    Python's error output names the exact line with unexpected leading spaces. Open fixme1.py in an editor and remove those extra spaces so the line aligns with the statements around it.
    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.

    nano inserts a literal tab character when you press Tab. If the rest of the file uses spaces, that tab triggers a TabError, or leaves indentation that looks right but is syntactically wrong. Use the space bar so the indentation matches 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 3Run the fixed script
    Observation
    The only reported error is that single IndentationError on the print line. Correcting that one line should let the script run 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.

Interactive tools
  • Strings ExtractorPull printable text from any binary, library, or image. ASCII and UTF-16 detection, configurable minimum length, flag-like highlight, no command line needed.
  • Regex TesterTest regular expressions against a string with live match highlighting, flag toggles, and common CTF pattern shortcuts.
  • Cyclic Pattern GeneratorGenerate de Bruijn cyclic patterns and find buffer overflow offsets. The browser equivalent of pwntools cyclic and cyclic_find.

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

Useful tools for General Skills

Where to go next