end parameter in python print statement and how to use it

end parameter in python print statement and how to use it:

print is used to print a line in python. By default, it adds one newline to the parameter that it is printing. For example, for the below program :

print("Hello World !!")

It will print the below output :

(base) ➜  programs python3 example.py
Hello World !!

As you can see here, it adds one newline to the string that it is printing.

Adding a different end parameter :

With Python 3, we can also add different end parameter using a second parameter. For example:

print("Hello World !!",end="#")

It will print the below output :

Hello World !!#

Another example :

print("Hello",end="#")
print("World !!")

It will print :

Hello#World !!

You might also like :