I am doing python reasonably well but I'm not sure on how to print a space in my code.
Usually I just type:
print("")
Is there a more efficient way I can do this?
I am doing python reasonably well but I'm not sure on how to print a space in my code.
Usually I just type:
print("")
Is there a more efficient way I can do this?
If I understood your question well, you want a "space" between the lines, and as some people already answered, \n
is the choice.
For example, in the following code I place one \n
to continue the text in the second line, and later I use \n\n
to go to a new line twice, so I get a blank line separating the text:
>>> print('Hi, I am line number 1!\nI am line number two, nice to meet you!\n\nAnd I am line number 4, why is line number 3 so silent?')
Result:
Hi, I am line number 1!
I am line number two, nice to meet you!
And I am line number 4, why is line number 3 so silent?
If you want to accomplish this task, just use "\n".
print("Hello\nHow are you doing?")
Result:
Hello
How are you doing?
Just put a space in between the string argument of print.
print 'a' + ' ' + 'b'
output: "a b"
If you meant a new line (vertical space) then the following works best.
print("\n")
The \n
character can be placed anywhere in a string and will be interpreted as a new line.