VOOZH about

URL: https://www.geeksforgeeks.org/python/how-to-use-quotes-inside-of-a-string-python/

⇱ How to use quotes inside of a string - Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to use quotes inside of a string - Python

Last Updated : 23 Jul, 2025

In Python programming, almost every character has a special meaning. The same goes with double quotes (" ") and single quotes (' '). These are used to define a character or a string. But sometimes there may arise a need to print these quotes in the output. However, the Python interpreter may raise a syntax error. Fortunately, there are various ways to achieve this.

Let us see a simple example of using quotes inside a String in Python.


Output
Hello, 'GeeksforGeeks'
Hello, "GeeksforGeeks"

Now let’s explore other different methods to use quotes inside a String.

Using Escape Sequence

Python escape sequence are used to add some special characters in to the String. One of these characters is quotes, single or double. This can be done using the backslash (\) before the quotation characters.


Output
Hello, "GeeksforGeeks"
Hello, 'GeeksforGeeks'
Hello, "GeeksforGeeks" and 'hey Geeks'

Using Triple Quotes

triple quotes (""" or ''') in Python work as a pre-formatted block. This also follows alternative quote usage, i.e., if double quotes are used to enclose the whole string, then direct speech should be in single quotes and vise-versa.


Output
Hello, 'GeeksforGeeks'
Hello, "GeeksforGeeks"
Hello, "GeeksforGeeks" And Hey Geeks
Comment
Article Tags: