Bird
Raised Fist0

Which of the following is the correct syntax to write a multi-line string in Python?

easy📝 Syntax Q3 of Q15
Python - File Reading and Writing Strategies
Which of the following is the correct syntax to write a multi-line string in Python?
A"This is a multi-line string"
B'This is a multi-line string\n'
C'''This is a multi-line string'''
D"This is a \ multi-line string"
Step-by-Step Solution
Solution:
  1. Step 1: Understand multi-line string syntax

    Triple quotes allow strings to span multiple lines including line breaks.
  2. Step 2: Check options for correct multi-line string

    '''This is a multi-line string''' uses triple quotes and includes a newline character \n correctly.
  3. Final Answer:

    '''This is a\nmulti-line string''' -> Option C
  4. Quick Check:

    Multi-line string = Triple quotes [OK]
Quick Trick: Use triple quotes for multi-line strings [OK]
Common Mistakes:
MISTAKES
  • Using single or double quotes without triple quotes
  • Trying to escape newlines incorrectly
  • Using backslash incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes