I would like to print a variable within quotation marks. I want to print out "variable"
I have tried a lot, what worked was:
'"', variable", '"'
– but then I have two spaces in the output -> " variable "
When I do print '"'variable'"'
without the comma I get a syntax error.
How can I print something within a pair of quotation marks?
you can use format
:
>>> s='hello'
>>> print '"{}"'.format(s)
"hello"
Learn about format here:Format
In 3x you can use f
:
>>> print(f"{s}")
hello