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 :
- Python calendar module HTMLCalendar class
- How to read the content of a specific column of csv file in Python
- How to ceil all values of an array using python numpy ceil
- Different ways to convert one boolean to string in python
- Python program to select an item randomly from a list
- write a python program to do a case insensitive string replacement
- Different ways in python to remove vowels from a string
- Python program to get random values from a list, dictionary, tuple or set
- Python program to find out the third largest number in a list
- Python tutorial pretty print JSON to console and file
- How to replace date and time of a python datetime object