Home »
Python »
Python programs
Python | How to print double quotes with the string variable?
Here, we are going to learn how to print double quotes with the string variable in python programming language?
By IncludeHelp Last updated : February 13, 2024
Problem statement
Given a string variable and we have to print the string using variable with the double quotes.
Printing double quotes with the string variable
By using some of the methods and escape sequence (double quotes escape sequence \") that can be added with the variable while printing the value of the variable.
The methods/ways to print the double quotes with the string variable are used in the given program, consider the program and see the output...
Python program to print double quotes with the string variable
#declare a string
str1 = "Hello world";
#printing string with the double quotes
print("\"%s\"" % str1)
print('"%s"' % str1)
print('"{}"'.format(str1))
Output
The output of the above program is:
"Hello world"
"Hello world"
"Hello world"
Python String Programs »
To understand the above program, you should have the basic knowledge of the following Python topics: