Python Forum
Print Function - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Print Function (/thread-7192.html)



Print Function - Jaks - Dec-27-2017

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


RE: Print Function - metulburr - Dec-27-2017

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.


RE: Print Function - Mekire - Dec-27-2017

sep is only relevant if you are passing multiple arguments to the print function:  
>>> print("+","-","*","/", sep=" sep ", end=" end!!!\n")
+ sep - sep * sep / end!!!
>>>



RE: Print Function - wavic - Dec-27-2017

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:
+,-