Why output produced with single quote and the 2nd output produced without quote | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why output produced with single quote and the 2nd output produced without quote

"dog" *2 output 'dogdog' print ("dog"* 2) output dogdog why??????

1st Jun 2017, 11:44 AM
Susovan Das
Susovan Das - avatar
1 Answer
0
the first output is a literal string. in cases where you have for example, \n, so, "dog\n"*2, and you feed it to the print function, the \n will be interpreted by the print function and you will see a newline inserted. in the second output, you see the result of print function. sure, insert a newline in the string here and you will see newline in the output. but the difference here is, you are seeing the print function's output.
1st Jun 2017, 11:54 AM
Venkatesh Pitta
Venkatesh Pitta - avatar