Python Forum

Full Version: Print Function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
i'm executing below 2 lines in Pycharm

print("+", sep=" ", end=" ")
print("-", sep=" ", end=" ")

I got the output like this

+ -

My question is,if we are executing print functions twice why it is coming in one line. with my knowledge it should be in next line.
can anyone tell me how it is executed in one line

Thanks in advance
That is how it should be. Although you dont need the sep argument if your using the same end. When you use end argument, you no longer have a newline at the end, but just a space.
sep is only relevant if you are passing multiple arguments to the print function:  
>>> print("+","-","*","/", sep=" sep ", end=" end!!!\n")
+ sep - sep * sep / end!!!
>>>
There are on one line because of the 'end' parameter. The default value is the new line symbol '\n'.

print('+')
print('-')
Output:
+ -
print('+', end=',')
print('-')
Output:
+,-