I'm writing a script that includes printing a 10 second countdown without a newline, and I want it to be compatible with both Python2 and Python3.
This is what I've tried:
for sec in range(10, 0, -1):
    try:
        print(" %d \r" % sec, end="")
    except SyntaxError:
        subprocess.call("printf \" %d \\r\"" % sec, shell=True)
    time.sleep(1)
And I'm getting this error:
    print(" %d \r" % sec, end="")
                             ^
SyntaxError: invalid syntax
It seems to me that SyntaxError should be getting caught.
I've tried researching the topic, and read the documentation on SyntaxError, but can't find anything that suggests why this is happening.
 
     
    