Back to Blog Home

How To Print New Line In Python

Jay Mishra| Python | 6 months, 3 weeks



 

You can simply use the new line character : ‘/n’ to print in new line in python.

 

For example, lets consider two strings a and b 

 

a = “Hello World” 

b = “Welcome To Enpointer”

 

Now if we go ahead and write them in a file like 

write.file(a)

write.file(“\n”)

write.file(b)

write.file(“\n”)

 

This will produce output as  :

Hello World

Welcome To Enpointer

 

Or you can also use the new line character ‘\n’ within the string as well to print in a new line.

For example,

a = “Hello World \nWelcome To Enpointer”

 

Now if we go and print like :

print(a)

 or if we want to write the output in file

write.file(a) 

 

This will produce output as :

 

Hello World

Welcome To Enpointer

 

 



Join 1000+ People Who Subscribe to Weekly Blog Updates

Back to Blog Home