Is there any way to print it without any spaces in Python?

Asked 1 years ago, Updated 1 years ago, 122 views

In C,

for(i=0; i<3; i++)
    printf(".");

Lower face

...

It came out

In Python,

for i in range(0,3):
    print(".")

Lower face

.
.
.

It comes out like this. How do I make it look like C?

python newline

2022-09-21 23:10

1 Answers

import sys
for i in range(0,3):
    sys.stdout.write('.')
from __future__ import print_function
#The following is the same as Python3 method
for i in range(0,3):
    print('.', end="")

If you want to empty the buffer, write as follows

print('.',end="",flush=True)


2022-09-21 23:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.