Find Mistake: Missing Indentation
Find the Mistake Beginner
Question
This code raises an IndentationError. What is wrong?
Code
def greet(name):
print(f"Hello, {name}")
Hint
The line after def should be indented.
Explanation
The function body is not indented. Python requires the body of a function to be indented (typically 4 spaces) relative to the def line. The fix is to indent the print statement.
Related Resources
Related Lessons
- Python Functions
Function indentation.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.