What are different types of quotes in Python?

There are different types of quotes in Python. Each quotation is used in different scenarios as per the requirement. The following are the different types of quotations which we can use in the python programming language.

  • Single quotes

  • Double quotes

  • Triple quotes

What are Single quotes?

Single quotes (' ') are used to create strings and characters in Python programming. Since the print() function accepts string values we can directly pass values to it wrapping them within the single quotes.


In this example, we will create a string using the single quotes and assign it to the variable before printing the output.

s = 'Welcome to Tutorialspoint'


Welcome to Tutorialspoint
<class 'str'>


In here, we are directly passing the string value to the print() function −

print('Python Programming Language')


Python Programming Language

What are Double quotes?

We can also use the Double quotes (" ") to create strings and characters. The functionality of single (') and double (") quotes is the same; you can use either one depending on your requirements.


In this example, we are creating a string value using the double quotes.

st = "Double quotes in python programming"


Double quotes in python programming
<class 'str'>


If we want to print a statement, we can also directly pass the desired text, placing it with in double quotes, to the print() function.

print("Double quotes used in print statement")


Double quotes used in print statement

What are Triple quotes?

The Triple quotes are used for commenting and representing the docString in the python.


In a part of the code, if we want to use the sentences which are not part of code lines, then we will pass those sentences in the triple quotes. The following is the code.

string = "Hello world"
'''The triple quotes are mainly used 
for commenting the lines in python programming language'''


The following is the output of the triple quotes used for commenting the lines. In the output we can see that the lines given in the triple quotes are not displayed in the output.

Hello world


Instead of the triple quotes we can also use the triple double quotes for commenting the lines in the code.

s = "Hello world"
"""The triple quotes are mainly used 
for commenting the lines in python programming language"""


Hello world

Updated on: 09-Sep-2023

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started