Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q7 of 15
Python - Basics and Execution Environment
Find the error in this code snippet:
def add(a, b):
return a + b
AMissing parentheses in function call
BNo error
CFunction name invalid
DReturn statement not indented
Step-by-Step Solution
Solution:
  1. Step 1: Check indentation rules in functions

    Python requires the return statement to be indented inside the function block.
  2. Step 2: Identify indentation error

    The return line is not indented, causing an IndentationError.
  3. Final Answer:

    Return statement not indented -> Option D
  4. Quick Check:

    Indent return inside function = D [OK]
Quick Trick: Indent all function code blocks properly [OK]
Common Mistakes:
MISTAKES
  • Not indenting return or body lines
  • Misunderstanding indentation importance
  • Assuming Python ignores indentation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes