Python how to print without newline

If you want to use print method and print without adding new line you can add this parameter: end=''

for i in range(0, 10):
    print(i, end='')

result:

0123456789

Adding space as separator

You can divide the print with spaces

for i in range(0, 10):
    print(i, end=' ')

result:

0 1 2 3 4 5 6 7 8 9

Adding comma as separator

Separating by comma and space

for i in range(0, 10):
    print(i, end=', ')

result:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9,

Adding semicolon as separator

You can create csv output easily in python using , end=';' to print function

for i in range(0, 10):
    print(i, end=';')

result:

0;1;2;3;4;5;6;7;8;9;

Related Article