Elangovan Nagarajan Elangovan Nagarajan - 5 months ago 34
Python Question

How does this syntax work: print("Hello", end="")

In python, I found I can have no new lines after printing by doing:

print("something", end="")
, how does this syntax where you say
work, and how and why would you want to have it in your own function declaration.
Sorry if this is a duplicate, but I don't know what this syntax is called.


This syntax is called keyword arguments (or named arguments). This is explained in the official Python tutorial here: https://docs.python.org/3/tutorial/controlflow.html#keyword-arguments

And the print documentation is here. https://docs.python.org/3/library/functions.html#print

If you still have questions after reading these documents, feel free to ask.