What is the output of this code snippet?
print(""" A B C """=="\nA\nB\nC\n")
What is going on in this puzzle? The basic idea is to show two different ways of writing the same multi-line string literal in Python.
The first is the direct way to write a multi-line string in Python: As a string with multiple code lines enclosed by triple-quotes
The second is a more concise way to write the same string. We specify the line breaks with the new line character ‘\n’.
These two ways of breaking lines in Python strings are the basis for advanced features and code snippets. Understanding them will increase your coding skills a bit further.
Are you a master coder?
Test your skills now!