1

I want to know, when I can use this expression: end="".

print('*',end="")
martineau
  • 119,623
  • 25
  • 170
  • 301

2 Answers2

4

Normally python appends a newline to each print statement, you can replace the newline with something of your choosing with the end paramter.

>>> print('hi')
hi
>>> print('hi', end='')
hi>>> print('hi', end='bye')
hibye>>>
Jon
  • 356
  • 3
  • 8
0

One of the default parameter to the print function is end = '\n'. So what that means is by default python inserts a newline right after your print statement. Most of the time this is handy and reduces having to use the newline every time. But sometimes this is not the case and we don't want it to insert a newline character in the end. So to override this default parameter we give an end argument to the print statement, and the statement will end with whatever you have provided. So in this case, we have over rode it to '', or nothing in the end, which cancels out the default newline character.

Dharman
  • 30,962
  • 25
  • 85
  • 135