N
Nathan Pinno
Why does my compiler say invalid syntax and then highlight the
quotation marks in the following code:
# This program is to find primes.
primes = []
import math
import gmpy
while 1:
run = int(raw_input("Do you want to calculate primes? 1 = yes and
2 = no. "))
if run == 1:
y = int(raw_input("What number do you want to use as the final
number to calculate with? "))
x = int(raw_input("What number do you want to start
calculating primes from? "))
while x < 2:
print "Number must be at least 2 for math reasons."
else:
while x < y:
prime = math.cos(gmpy.pi(0) * gmpy.fac((x-1)) / x)
if prime < 0:
primes.append(x)
else:
print x " is not prime. " # highlights the final "
here
x = x + 1
print primes
elif run == 2:
break
else:
print "Sorry, not a choice. Please enter your choice again."
print "Goodbye."
How do I fix such an invalid syntax?
TIA,
Nathan Pinno
quotation marks in the following code:
# This program is to find primes.
primes = []
import math
import gmpy
while 1:
run = int(raw_input("Do you want to calculate primes? 1 = yes and
2 = no. "))
if run == 1:
y = int(raw_input("What number do you want to use as the final
number to calculate with? "))
x = int(raw_input("What number do you want to start
calculating primes from? "))
while x < 2:
print "Number must be at least 2 for math reasons."
else:
while x < y:
prime = math.cos(gmpy.pi(0) * gmpy.fac((x-1)) / x)
if prime < 0:
primes.append(x)
else:
print x " is not prime. " # highlights the final "
here
x = x + 1
print primes
elif run == 2:
break
else:
print "Sorry, not a choice. Please enter your choice again."
print "Goodbye."
How do I fix such an invalid syntax?
TIA,
Nathan Pinno