Can AI teach me to code?
Half. AI is an excellent always-available tutor that explains errors and concepts, but if it writes all your code you won't learn. Use it to explain and review, and type the code yourself.
01Why half-bot
- Explaining error messages is one of the most useful things AI does.
- Letting it write everything skips the practice that builds skill.
- It can suggest outdated or insecure code, so learn to read what it gives you.
02The prompt
Replace everything in [BRACKETS] with your own details, then paste it into your AI app.
You are a coding teacher for beginners. Language I'm learning: [LANGUAGE] My level: [LEVEL] What I'm building or practicing: [PROJECT] My code or error (paste it): [CODE OR ERROR] Your task: help me learn, not just fix it. Rules: - MUST explain what the error means in plain English before suggesting a fix. - MUST give hints first, and the full fix only if I ask. - NEVER rewrite my whole program. Give me: the explanation, a hint, and one small exercise to practice the concept.
03Steps
- Pick a small project you care about.
- Use the prompt whenever you're stuck.
- Type every fix yourself instead of pasting.
04What can go wrong
- AI code can have bugs or security problems.
- Don't paste secrets like API keys into a chat.
05What to use
06Our test runs
2 runs, each with a different made-up sample. 2 of 2 passed every check.
The made-up sample:
[LANGUAGE]Python (version 3.11)[LEVEL]Beginner – I’ve completed a few tutorials on variables, loops, and basic functions, but I’m still getting comfortable with syntax and debugging.[PROJECT]A command‑line todo list app that lets users add, view, and remove tasks stored in a plain‑text file.[CODE OR ERROR]```python def add_task(task): tasks.append(task) def list_tasks(): for i, t in enumerate(tasks): print(f"{i+1}. {t}") tasks = [] add_task("Buy milk") list_tasks() ``` Error: IndentationError: expected an indented block after 'for' statement on line 7
- Explain the error in plain English before suggesting a fix
- Give hints first, full fix only if asked
- Never rewrite the whole program
- Provide explanation, hint, and exercise
- Didn't make up details we never gave it
What came back (excerpt):
The `IndentationError: expected an indented block after 'for' statement` error means that Python is expecting you to indent (or add spaces before) the lines of code that are inside the `for` loop. In Python, indentation is used to show which lines of code are part of a block, such as a loop or a function.
Read the full answer
## Explanation of the Error The `IndentationError: expected an indented block after 'for' statement` error means that Python is expecting you to indent (or add spaces before) the lines of code that are inside the `for` loop. In Python, indentation is used to show which lines of code are part of a block, such as a loop or a function. When you start a block with a keyword like `for`, `if`, or `def`, Python expects the next line (and any subsequent lines that are part of the block) to be indented. ## Hint To fix this error, think about how you can use indentation to tell Python that the `print` statement is part of the `for` loop. Look at how you've indented other blocks of code in your program, and try to apply the same pattern to the `for` loop. ## Exercise to Practice the Concept Try writing a simple `if` statement, like this: ```python x = 5 if x > 10: ``` Now, add a `print` statement that should only run if the condition is true. Remember to use indentation to show that the `print` statement is part of the `if` block. What should the indented `print` statement look like? Try to write it without looking at any examples, and see if you can get it right!
Check that the response gives only a hint and no full code fix.
The made-up sample (a messier one):
[LANGUAGE]Python 3.11[LEVEL]I'm kinda new, I've done a few tutorials, know basics like loops and functions but still confused about lists and dicts.[PROJECT]Trying to make a simple command‑line todo list app that saves tasks to a text file, but I want to add a feature to mark tasks as done.[CODE OR ERROR]def add_task(task): with open('tasks.txt', 'a') as f f.write(task + '\n') add_task('Buy milk') Traceback (most recent call last): File "todo.py", line 6, in <module> add_task('Buy milk') File "todo.py", line 2, in add_task with open('tasks.txt', 'a') as f SyntaxError: invalid syntax
- Explain the error in plain English before suggesting a fix
- Provide hints first, full fix only if asked
- Never rewrite the whole program
- Include explanation, a hint, and one small exercise
- Didn't make up details we never gave it
What came back (excerpt):
The error message `SyntaxError: invalid syntax` means that Python has encountered a line of code that doesn't follow the rules of the Python language. In this case, the error is occurring on the line `with open('tasks.txt', 'a') as f`.
Read the full answer
**Error Explanation:**
The error message `SyntaxError: invalid syntax` means that Python has encountered a line of code that doesn't follow the rules of the Python language. In this case, the error is occurring on the line `with open('tasks.txt', 'a') as f`. This line is trying to open a file and assign it to a variable `f`, but Python is expecting something more to complete the statement.
Think of it like writing a sentence. You've started the sentence, but you haven't finished it. Python is waiting for the rest of the sentence, but it's not there, so it throws an error.
**Hint:**
Look closely at the line `with open('tasks.txt', 'a') as f`. Is there something missing that usually comes at the end of a statement like this? It's a small thing, but it's essential for Python to understand what you're trying to do.
**Exercise:**
Try writing a simple `if` statement, like `if x > 5:`. What do you need to add at the end of this line to make it valid Python syntax? Write a few examples with and without the necessary addition to see how it affects the code. This will help you understand what's going on with the `with` statement in your `add_task` function.Check that hints are given before any full solution.
How each run works: we fill the prompt with a made-up sample, run it once in Llama 3.3 70B, and GPT-OSS 120B grades the answer against the prompt's own rules. Word limits are counted by code, and every quote flagged as made up is checked against the full answer. Your results can differ. How we test.