How to print without a newline or space
To print without a newline in Python, you can use the end
argument for the print()
function. By default, print()
adds a newline character at the end of the string being printed, but you can change this by setting end
to an empty string:
This will print "HelloWorld", with no space or newline characters between the two strings.
You can also use the sep
argument to specify a string to separate the items being printed. By default, sep
is set to a single space character, so you can set it to the empty string to eliminate the space between the items:
This will print "HelloWorld", with no space or newline characters between the two strings.