Printing the " symbol


#1

Hello!
What should I do to print out the " symbol in in the print message?


#2

What exercise you're at (link?) and can you elaborate your question?
do you want to print string inside a string like this ' "hello" ' ?


#3

You could do this in one of three ways:
1) Use single and double quotes together:
print '"A word that needs quotation marks"'
"A word that needs quotation marks"
2) Escape the double quotes within the string:
print "\"A word that needs quotation marks\""
"A word that needs quotation marks"
3) Use triple-quoted strings:
print """ "A word that needs quotation marks" """
"A word that needs quotation marks"


#4

It was the general question, I just hadn't found a way to tag it properly


#5

Yea,correct!
D - double quoted strings
S - Single quoted string
T - Triple quotes (single ''' or double """ )

1.D(S)
2.S(D)
3.T(S) / T(D)
4.Use of escape character.

#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.