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?
Submitted by IncludeHelp, on November 28, 2018

Problem statement: Given a string variable and we have to print the string using variable with the double quotes.


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...

#declare a string
str1 = "Hello world";

#printing string with the double quotes
print("\"%s\"" % str1)
print('"%s"' % str1)


"Hello world"
"Hello world"
"Hello world" 

Other python string programs...

Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.