While I was helping a junior developer on my team who was struggling with printing strings that contained quotes in Python.
At first glance, it looks simple. But when you try to print a sentence like He said, “Python is amazing!”, Python throws errors if you don’t format it correctly.
I’ve been working with Python for more than 10 years, and this is one of those little things that can confuse beginners. So in this tutorial, I’ll show you 5 simple methods to print a string with quotes in Python.
Method 1 – Use Single and Double Quotes Together
One of the easiest ways is to mix single and double quotes.
If your string contains double quotes, wrap the entire string in single quotes.
# Example: Printing a sentence with double quotes
print('He said, "Python is amazing!"')Output:
He said, "Python is amazing!"You can refer to the screenshot below to see the output.

And if your string contains single quotes, wrap it in double quotes:
# Example: Printing a sentence with single quotes
print("It's a sunny day in New York.")Output:
It's a sunny day in New York.This method is quick and works in most cases.
Method 2 – Use Escape Characters
Sometimes, you may need both single and double quotes in the same string. In that case, use the backslash (\) escape character.
# Example: Using escape characters
print("She said, \"It's a beautiful day in California!\"")Output:
She said, "It's a beautiful day in California!"You can refer to the screenshot below to see the output.

The backslash tells Python to treat the quote as part of the string instead of ending it.
Method 3 – Use Triple Quotes
Python also supports triple quotes (''' or """). These are useful for multi-line strings, but they also work great when you want to include quotes inside.
# Example: Using triple quotes
print("""The professor said, "Don't forget your homework." """)Output:
The professor said, "Don't forget your homework."You can refer to the screenshot below to see the output.

This method is clean and avoids too many escape characters.
Method 4 – Use the repr() Function
Another trick I often use is the repr() function, which returns the string with quotes included.
# Example: Using repr()
text = 'Python is fun'
print(repr(text))Output:
'Python is fun'This is handy when debugging because you see the string exactly as Python stores it.
Method 5 – Use f-Strings (Formatted Strings)
If you’re working with variables, f-strings make it easy to include quotes.
# Example: Using f-strings
city = "Chicago"
print(f'She said, "I love {city}!"')Output:
She said, "I love Chicago!"This is my favorite method when working with dynamic text.
Bonus Tip – Print Quotes Multiple Times
If you need to print multiple quotes, you can simply multiply the string.
# Example: Printing quote marks multiple times
print('"' * 5)Output:
"""""Conclusion
Printing strings with quotes in Python may look tricky at first, but once you know these methods, it becomes second nature.
- Use single/double quotes together for simple cases.
- Use escape characters when both types of quotes are needed.
- Use triple quotes for multi-line or cleaner formatting.
- Use
repr()for debugging. - Use f-strings when working with variables.
I hope you found this tutorial helpful. Next time you need to print a string with quotes in Python, you’ll know exactly which method to pick.
You may also read:
- Check If Two Dictionaries Are Equal in Python
- Python Copy Dict Without One Key
- Convert a Dict to String in Python
- Python Nested Dictionary to JSON

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.