+ 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
3 odpowiedzi
+ 6
You can use the end keyword to specify the whitespace between two print function!
print("Hello", end=" ")
print("World!")
+ 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")
+ 2
thanks