×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

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:

Related Programs

Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.