How can I skip or jump to a new line while printing?

Hello, I was wondering, how can I tell python program to go to next line after printing something using print()? Like, in Java, we use System.out.println() to tell it to go to next line.

1 Like

You can use \n in your string to jump to a new line, but print() will also work depending on what you’re trying to do. A couple examples that both print to lines 1 and 3:

print('line1 \n\nline3')
>line1
>
>line3
print('line1')
print()
print('line3')
>line1
>
>line3
5 Likes

Hello there!

I am new here! :slight_smile:

How come when I copy paste the following and run it an error appears?

print(‘line1 \n\nline3’)

line1

line3
print(‘line1’)
print()
print(‘line3’)
line1

line3

Thanks!

var=“India”
print(“Value of var=”,var)

It works fine. Can anyone please tell when do we insert %s after =

The text following an > arrow is to indicate what the output would be. If you try to enter line1 into your code editor it will give an error because it doesn’t know what to do with that text. Python would think its an undefined variable.