Print String with Quotes in Python

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.

how to print quotation marks in python

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.

python quotes

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.

python print quotes

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:

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.