Bird
0
0

Why does this code cause an error?

medium📝 Debug Q7 of 15
Python - Basics and Execution Environment
Why does this code cause an error?
print('Begin')
# print('Skip')
"""This comment is not closed properly
Aprint('Begin') is missing parentheses
BThe # comment is invalid syntax
CThe triple-quoted string is not closed, causing a syntax error
DPython does not allow comments after print statements
Step-by-Step Solution
Solution:
  1. Step 1: Check comment syntax

    The triple-quoted string starting with """ is not closed, leading to a syntax error.
  2. Step 2: Verify other lines

    The # comment is valid, and print syntax is correct.
  3. Final Answer:

    Unclosed triple-quoted string causes syntax error -> Option C
  4. Quick Check:

    Unclosed triple quotes cause errors [OK]
Quick Trick: Always close triple quotes to avoid syntax errors [OK]
Common Mistakes:
MISTAKES
  • Thinking # comments cause errors
  • Ignoring unclosed triple quotes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes