0

In python 2 i have this simple loop

while True:
    for i in ["/", "-", "|", "\\", "|"]:
        print "%s\r" % i,

It produces a loop of those symbols, on the same line, replacing each character in place (so you never see more than 1 symbol)

However, in python3

while True:
    for i in ["/", "-", "|", "\\", "|"]:
        print("%s\r" % i,)

The same code, when fixed for syntax, prints each symbol on a new line

Not sure what I am missing, would appreciate the help

to0ns88
  • 41
  • 10
  • Each `print` statement in Python 3 produces a new line. That behavior is to be expected. – ifconfig Jul 30 '17 at 01:03
  • 2
    Summing up the duplicate: the syntax to print without a newline in Python 2 is a trailing comma on the `print` statement, but the argument in Python 3 is `end`: `print("%s\r" % i, end="")`. – Ry- Jul 30 '17 at 01:04

0 Answers0