Q:

Python | How to print double quotes with the string variable?

belongs to collection: Python String Programs

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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)
print('"{}"'.format(str1))

Output

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python String Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Python | Ignoring escape sequences in the string... >>
<< Python | Assign Hexadecimal values in the string a...