Print without newlines and spacing in Python

Problem description

As you already know everytime you call print in Python it creates new line. For example:

print("hi")
print("everyone")

Return:

hi 
everyone

Socondly, when you pass multiple strings to one print, there will be spaces between them. Look:

print("hi", "everyone")

Return:

hi everyone

The question is how to avoid newlines and spacing or any separators.

Problem sollution

Python's print has two optional keyword parameters:

  • sep - string to print between arguments. Default value: ' ' (space)
  • end - string to print at the end. Default value: '\n' (new line)

To delete all of spaces and newlines, set sep and end values to empty string:

print("hi", sep='', end='')
print("everyone", sep='', end='')

Return:

hieveryone

Other case:

print("hi", "everyone", sep='', end='')

Returns the same thing:

hieveryone