0

How can I print all of the output on the same line? Something like ",,,key, value". The below creates a newline for every preceding ','.

for i in range(0, depth):
    print(',')
print("{}, {}".format(key, value))
Bill
  • 915
  • 2
  • 13
  • 23
  • use the `end` flag within the `print` call? – gold_cy Apr 02 '19 at 00:28
  • 1
    @Ruturaj: The `flush=True` part isn't necessary if you expect to print a newline soon. You'd want to avoid it if you were printing without sleeps or blocking calls so as to avoid spending excessive time on per-print system calls for small outputs. – ShadowRanger Apr 02 '19 at 00:29

0 Answers0