New line
is a term used to describe the end of a line and jump to the next or new line in a text file or console. Most of the programming languages as well as Python provides the \n
character sequence to express and create a new line.
Create a New Line in Console
The newline is created with the \n
characters. By default the print() method adds the end of line character at the end of the provided data implicitly. Lets make some examples.
print("This is a line")
print("This is a new line\n")
print("\nThis is a two new line\n")
print("This\nis\na\ntwo\nnew\nline\n")

Disable New Line in print() Method
print() method provides the end of the line by default and if we want we can disable this new line. Generally, we use the print() method just providing the text we want to print but there are also other parameters that can be provided to the print() method. end the parameter is used to provide the end of the given text which is by default \n
or end of line or new line. Here we can disable this by setting empty or another value like below.
print( "This is a line" )
print( "This is a line" , end="\n" )
print( "This is a line" , end="" )
print( "This is a line" , end="--" )
