I know this question may well be the silliest question you've heard today, but to me it is a big question at this stage of my programming learning.
Why is the second empty line needed in this Python code? What does that line do?
print 'Content-Type: text/plain'
print ''
print 'Hello, world!'
It prints an empty line, just as you have said. It will leave a blank line in the output. The print statement prints its arguments, and then a newline, so this prints just a newline.
Using an empty print() function In Python, multiple uses of the print() function can display the output in different lines. See the following example. This is because the print() function has a parameter end , which is \n by default. The end parameter adds this character to the end of the output.
Using Print() function with a newline character To Print Blank Line In Python.
The new line character in Python is \n . It is used to indicate the end of a line of text. You can print strings without adding a new line with end = <character> , which <character> is the character that will be used to separate the lines.
It prints an empty line, just as you have said. It will leave a blank line in the output. The print statement prints its arguments, and then a newline, so this prints just a newline.
You could accomplish the same thing with just:
print
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With