0

I have this code:

zeroct_pre = 0
total_pre = 10
pct = round((zeroct_pre/float(total_pre))*100,1)
print 'Number of >= 1 pre-submissions: ' + str(zeroct_pre) + ' (' + str(pct) + '%)'

But gives this error:

  File "count.py", line 4
    print 'Number of >= 1 pre-submissions: ' + str(zeroct_pre) + ' (' + str(pct) + '%)'
                                       ^
SyntaxError: invalid syntax

I've tried changing all ' to " but same error. I'm running Python 3.5.1, any thoughts on why? This code was just working and I've made no changes (no whitespace changes etc).

Zeno
  • 1,769
  • 7
  • 33
  • 61

1 Answers1

-1

In Python 3, print is now a function. You're trying to use the Python 2 syntax for printing.

Take a look at this: https://docs.python.org/3/whatsnew/3.0.html

You need to add parenthesis:

print ('Number of >= 1 pre-submissions: ' + str(zeroct_pre) + ' (' + str(pct) + '%)')
Harrison
  • 5,095
  • 7
  • 40
  • 60