+ 1

How can I not have a new line at the end of every print statement in python?

How can I not have a new line at the end of every print function? Python automatically adds a new line at the end unlike cout in cpp and I would like to know how to override that. Or is there a different function I have to use? Thank you

28th May 2018, 3:01 AM
Rora
3 Answers
+ 6
You can use the end keyword to specify the whitespace between two print function! print("Hello", end=" ") print("World!")
28th May 2018, 3:04 AM
777
777 - avatar
+ 3
When using the end, your string can contain zero characters so the next print immediately follows the previous. print("H", end="") print("ello") to print: Hello or even: print("H", end="ello\n")
28th May 2018, 11:41 AM
John Wells
John Wells - avatar
+ 2
thanks
28th May 2018, 3:13 AM
Rora