End Parameter:

It is set by default that in Python print() function will end when a new line starts. There is a parameter known by the name ‘end’ whose value is ‘\n’ by default. This statement is found useful when we want to end a statement with a particular string or character in python for data science.

Note: This function won’t work in Python 2. So, only use it when in Python 3.

# ends the output with a <space>

print(“Learn Python at” , end = ‘ ‘)

print(“PST Analytics”, end = ‘ ‘)

Output:

Learn Python at PST Analytics

Let’s look at another example. This time with a different character.

 

# end function with the output ‘@’

print(“Python, SAS and Tableau” , end = ‘@’)

print(“PST Analytics”)

Output:

Python, SAS and [email protected] Analytics

If you want to learn more about python for data sciencePython for Data Science then you can check this and this.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.