How to Get String Between Double Quotes in Python

In this tutorial, we will learn how to get string between double quotes in Python programming. In order to define a string in Python we use double quotes. Basically, we place the series of words or characters between the double or single quotations to define a string in python. So, it is very confusing for the coders who want to get the string in double or a single quote.

Let’s understand with examples-

As already mentioned, We define a string in Python by placing the series of characters or words between double or single quotations like this-

print ("Dips")


print ('Dips')

In the above code segment, Printing Dips, Which is a string. We can also do it using a variable. Like this-

Name = "My Name is Dips"


Name = 'My Name is Dips'

We print these strings we will get output like this-

My Name is Dips

But, What if we want to get a part of the output string in double quotes? like this-

I am “Dips” from Canada.

Use double Quotes in String in Python Programming

We can use print quotations in the string using the backslash (\). The backslash is one of the escape characters in Python programming.

Let’s understand with the example-

print ("I am \"Dips\" from Canada")

Here is the output we will get-

How to use double quotes in string in Python

Single Quotes in String in Python

Sometimes, we may need to print some words in between single quotes in Python. We can do so also using the backslash (\) escape character.

Let’s have an example-

Let’s print the sentence- The Python ‘Programming is fun’ for coders.

print ("The Python \'Programming is fun\' for coders.")

Other Question And Answers Related to Quotations in String

When we were doing some research on this topic we found that learners are seeking the answers to many questions related to quotations in Python. We are happy to cover some of them.

How to print double quotes in Python?

We use a backslash which is one of the escape characters and the double quotes sign in order to print double quotes in the string.

Example- print ("It is fun to learn \"Python\" programming")

Difference Between Single and Double Quotes in Python

There is no difference between single and double quotes in python if you want to define a string.

How to Remove Double Quotes From the String in Python?

There are many functions that you can use to replace double quotes from the string in Python but the most simple one is the replace() function.

The replace() function is used to replace the part of the string with another string.


a= 'Codi"ng is f"un'
b= a.replace('"','')
print (b)


Coding is fun

How replace function work?

Well, in the replace() function we have to pass two arguments separated by a comma. We have to place the string we want to replace as the first argument and the second argument to replace with.

So in our example code, we are replacing double quotes with an empty string.


We can use a backslash (Escape Character) in python to print double quotes or single quotes. In this tutorial, we have explained how to get double quotes in the string with some really helpful examples.

Leave a Comment