-3

The program list the prime numbers from 1 to 100, but when running it I get and syntax error on the "print p". Whats wrong??

for p in range(2, n+1):
    for i in range(2, p):
        if p % i == 0:
            break
        else:
            print p
print ("Done")
Tanveer Alam
  • 5,185
  • 4
  • 22
  • 43

1 Answers1

0

Are you using Python 3? If so, print is a function, and always requires parenthesis when you call it. For example:

print(p)
Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328