Bird
0
0

Find the error in this code that tries to print multiple lines:

medium📝 Debug Q14 of 15
Python - File Reading and Writing Strategies
Find the error in this code that tries to print multiple lines:
text = '''Line 1
Line 2
Line 3'
print(text)
AMissing closing triple quotes causes SyntaxError
BUsing single quotes inside triple quotes is not allowed
Cprint() function is missing parentheses
DNo error, code runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Check string delimiters

    The string starts with triple single quotes ''' but ends with a single quote ', causing a syntax error.
  2. Step 2: Identify error type

    Python expects matching triple quotes to close the string. Mismatched quotes cause SyntaxError.
  3. Final Answer:

    Missing closing triple quotes causes SyntaxError -> Option A
  4. Quick Check:

    Triple quotes must open and close properly [OK]
Quick Trick: Triple quotes must match exactly at start and end [OK]
Common Mistakes:
  • Ending triple-quoted string with single quote
  • Forgetting to close triple quotes
  • Assuming print syntax error instead

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes