This guide explains Single Quotes vs Double Quotes vs Triple Quotes through a focused example and practical reasoning. No prior knowledge of this specific operation is required.
Understanding the Concept
Single and double quotation marks create ordinary strings; triple quotes allow literal newlines and quotes inside longer text. Choose the style that requires fewer escapes, and use triple quotes carefully for indentation.
When You Would Use This
Write text containing an apostrophe and a quoted phrase.
Step-by-Step Example
first_message = "It's ready"
second_message = 'The note says "done"'
multiline_message = """Line one
Line two"""
print(first_message)
print(second_message)
print(multiline_message)
How the Example Works
The first two lines avoid unnecessary escapes by choosing the other quote style. The triple-quoted value preserves a newline between Line one and Line two.
Example Output
It's ready
The note says "done"
Line one
Line two
Try It Yourself
Write a two-line announcement containing both kinds of quotation marks.
Common Beginner Mistakes
- Forgetting to close a quotation mark.
- Assuming triple-quoted text automatically removes indentation from its contents.
- Using triple-quoted expressions as comments instead of proper comments when side effects matter.
Key Takeaways
- Single and double quotation marks create ordinary strings; triple quotes allow literal newlines and quotes inside longer text.
- The first two lines avoid unnecessary escapes by choosing the other quote style.
- Avoid this mistake: Forgetting to close a quotation mark.