How to print spaces in Python?

How to print spaces in Python?

Heres a short answer

x= 

This will print one white space

print(x)

This will print 10 white spaces

print(10*x) 

Print 10 whites spaces between Hello and World

print(fHello{x*10}World)

If you need to separate certain elements with spaces you could do something like

print hello, there

Notice the comma between hello and there.

If you want to print a new line (i.e. n) you could just use print without any arguments.

How to print spaces in Python?

A lone print will output a newline.

print

In 3.x print is a function, therefore:

print()

Leave a Reply

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