-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
  • 4,987
  • 3
  • 20
  • 41

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
  • 124,861
  • 31
  • 240
  • 314