Here, we will figure out how to print twofold statements with the string variable in a python programming language?
Issue articulation: Given a string variable and we need to print the string utilizing variable with the twofold statements.
Arrangement:
By utilizing a portion of the techniques and escape grouping (twofold statements escape succession \”) that can be included with the variable while printing the estimation of the variable.
The strategies/approaches to print the twofold statements with the string variable are utilized in the given program, consider the program and see the output…
Program:
#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"