in fact this should not be a problem because it\'s fairly basic. I just want to print out an array of categories, but in one line and separated by comma.
for ent
You are almost certainly experiencing output buffering by line. The output buffer is flushed every time you complete a line, but by suppressing the newline you never fill the buffer far enough to force a flush.
You can force a flush using flush=True
(Python 3.3 and up) or by calling the flush()
method on sys.stdout
:
for entry in categories:
print(entry, ", ", end='', flush=True)
You could simplify that a little, make ,
the end
value:
for entry in categories:
print(entry, end=', ', flush=True)
to eliminate the space between the entry and the comma.
Alternatively, print the categories as one string by using the comma as the sep
separator argument:
print(*categories, sep=', ')